Skip to content

Not inference type of subclass method's argument when --noimplicitAny. #21293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
GongT opened this issue Jan 19, 2018 · 4 comments
Closed

Not inference type of subclass method's argument when --noimplicitAny. #21293

GongT opened this issue Jan 19, 2018 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@GongT
Copy link

GongT commented Jan 19, 2018

TypeScript Version: 2.7.0-dev.20180118

Search Terms: type inference, noimplicitAny

Code

interface ITest { a: number; }
abstract class Base {
	protected abstract handle(foo: ITest): void;
}
class Child extends Base {
	handle(bar) { }
}

Expected behavior:
argument bar will have infered type ITest

Actual behavior:
error TS7006: Parameter 'bar' implicitly has an 'any' type.

Playground Link: Link


I know the bar can have any type implements ITest, but the strange thing is:
When I remove --noimplicitAny, tsserver will tell me bar has a a property. But with --noimplicitAny, tsserver can not tell me any thing but an error.

If bar can not have any other type do not implements ITest, why not infer bar as ITest?

@AngryPowman
Copy link

It's very helpful to me

@ghost
Copy link

ghost commented Jan 19, 2018

When I remove --noimplicitAny, tsserver will tell me bar has a a property.

Are you sure? When I tried this without --noImplicitAny it's just any, and there are no completions at all.

@RyanCavanaugh
Copy link
Member

Duplicate #1373

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jan 19, 2018
@GongT
Copy link
Author

GongT commented Jan 20, 2018

@Andy-MS

OK, I found that WebStorm's auto completion are proveided by it's own "JavaScriptLanguage", not tsserver by typescript package.

When I use plain tsserver, bar is just any. no completions.

@GongT GongT closed this as completed Jan 20, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants