Skip to content

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

Closed
@GongT

Description

@GongT

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions