Skip to content

Incorrect error message when overloaded function is called with invalid parameter #12313

Closed
@bjouhier

Description

@bjouhier

TypeScript Version: 2.0.3

Code

function foo(x: 'a'): void;
function foo(x: 'b'): void;
function foo(x: 'c'): void;
function foo(x: 'a' | 'b' | 'c') {}

foo('d');

Expected behavior:

Error: Argument of type '"d"' is not assignable to parameter of type '"a" | "b" | "c"'

Actual behavior:

Error: Argument of type '"d"' is not assignable to parameter of type '"c"'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions