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

Functions passed as an argument to other functions are not type checked as expected #6333

Closed
michaelmesser opened this issue Jan 3, 2016 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@michaelmesser
Copy link

I expected the following code to produce an error as function a could pass an argument that is not a string to function b.

Code:

declare function a(f: (v: Object) => string): void
declare function b(f: string): string
a(b)

Expected Result:

error TS2345: Argument of type '(f: string) => string' is not assignable to parameter of type '(v: Object) => string'.
  Types of parameters 'f' and 'v' are incompatible.
    Type 'Object' is not assignable to type 'string'.

Actual Result:
No error

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jan 4, 2016
@RyanCavanaugh
Copy link
Member

See e.e.g #6102

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 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

2 participants