Skip to content
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

Lack of type checking for callback parameters #15579

Closed
falsandtru opened this issue May 4, 2017 · 3 comments
Closed

Lack of type checking for callback parameters #15579

falsandtru opened this issue May 4, 2017 · 3 comments
Labels
Fixed A PR has been merged for this issue Question An issue which isn't directly actionable in code

Comments

@falsandtru
Copy link
Contributor

falsandtru commented May 4, 2017

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'.
@mhegazy
Copy link
Contributor

mhegazy commented May 5, 2017

@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label May 5, 2017
@falsandtru
Copy link
Contributor Author

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) and f(ev => g(ev)). Are you really choosing the current inconsistency?

@RyanCavanaugh
Copy link
Member

Suffice to say we've thought about this problem a lot and are sticking with the current situation.

@ahejlsberg ahejlsberg added the Fixed A PR has been merged for this issue label Sep 21, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

4 participants