Skip to content

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

Closed
@JsonFreeman

Description

@JsonFreeman
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'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions