Skip to content

Bind does not preserve function return type #16796

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

Closed
Jameskmonger opened this issue Jun 28, 2017 · 3 comments
Closed

Bind does not preserve function return type #16796

Jameskmonger opened this issue Jun 28, 2017 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@Jameskmonger
Copy link

TypeScript Version: 2.4.0

Code

function foo<T>(provider: () => T): T { return undefined; }
function giveMeTrue(): boolean { return true; }

const okay: boolean = foo(giveMeTrue); // okay
const notOkay: boolean = foo(giveMeTrue.bind(this)); // type '{}' is not assignable to type 'boolean'

Expected behavior:

Both should be okay - bind does not change the return type of the function.

Actual behavior:

bind changes the function return type to any.

@jesseschalken
Copy link
Contributor

@kitsonk
Copy link
Contributor

kitsonk commented Jun 28, 2017

Dupe of #212

@Jameskmonger
Copy link
Author

Closed as duplicate of #212

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jun 28, 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
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants