Skip to content

Overload resolution produces an incorrect error when type arguments don't satisfy the first overload #807

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
JsonFreeman opened this issue Oct 2, 2014 · 2 comments
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@JsonFreeman
Copy link
Contributor

JsonFreeman commented Oct 2, 2014

declare function f<T extends Number>(x: T): T;
declare function f<T extends String>(x: T): T

var v = f<string>("");

Expected: The second overload gets picked and there is no error.
Actual: An error:
error TS2343: Type 'string' does not satisfy the constraint 'Number':
Property 'toFixed' is missing in type 'String'.

@JsonFreeman JsonFreeman added the Bug A bug in TypeScript label Oct 2, 2014
@JsonFreeman
Copy link
Contributor Author

I have a fix for this bug.

@JsonFreeman JsonFreeman self-assigned this Oct 2, 2014
@sophiajt sophiajt added this to the TypeScript 1.3 milestone Oct 2, 2014
@mhegazy mhegazy modified the milestones: TypeScript 1.4, TypeScript 1.3 Oct 7, 2014
JsonFreeman added a commit that referenced this issue Oct 23, 2014
@JsonFreeman
Copy link
Contributor Author

Fixed by #951

@JsonFreeman JsonFreeman added the Fixed A PR has been merged for this issue label Nov 26, 2014
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants