-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
TypeScript Version: 2.4.0
Code
interface IPage {
method: (ev: string | number) => any;
}
class Page implements IPage {
method(e): any {
// this "e" is implicitly any
}
}
let x = new Page();
x.method = (e) => {
// this "e" is inferred to be 'string | number'
}Expected behavior:
The method override in Page should be inferred type string | number.
Actual behavior:
The method override in Page is implicitly the any type.
This seems like it should instead infer the parent type, because
- instance overrides already have this sort of inference (see the Contextual Type example about
window.onmousedown), and - if the class's override signature was something like
method(e: object): any, there would be an error that says the class wasn't matching the interface's signature. (Class 'Page' incorrectly implements interface 'IPage'.)
timruffles, JaakkoLipsanen and oriSomething
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created