Closed
Labels
FixedA PR has been merged for this issueA PR has been merged for this issueQuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
TypeScript Version: master
Code
function f(g: (ev: Event) => any) { }
function g(ev: MouseEvent) { }
f(g);
f(ev => g(ev));Expected behavior:
$ node built/local/tsc.js index.ts --noEmit --strict
index.ts(3,3): error ...
index.ts(4,11): error TS2345: Argument of type 'Event' is not assignable to parameter of type 'MouseEvent'.
Property 'altKey' is missing in type 'Event'.
Actual behavior:
$ node built/local/tsc.js index.ts --noEmit --strict
index.ts(4,11): error TS2345: Argument of type 'Event' is not assignable to parameter of type 'MouseEvent'.
Property 'altKey' is missing in type 'Event'.
Metadata
Metadata
Assignees
Labels
FixedA PR has been merged for this issueA PR has been merged for this issueQuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Activity
mhegazy commentedon May 5, 2017
https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-function-parameters-bivariant
falsandtru commentedon May 6, 2017
I didn't know that well because the FAQ doesn't say specific definitions of types of Animal and Dog. But it seems like you can keep the consistency of
f(g)andf(ev => g(ev)). Are you really choosing the current inconsistency?RyanCavanaugh commentedon May 8, 2017
Suffice to say we've thought about this problem a lot and are sticking with the current situation.