8000 Function overloads don't play nice with unions of string literals · Issue #16053 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content
Function overloads don't play nice with unions of string literals #16053
Closed
@fongandrew

Description

@fongandrew

TypeScript Version: 2.3.2

Code

function test(a: "A"): any;
function test(b: "B"): any;
function test(ab: "A"|"B"): any { }

declare var u: "A"|"B";
test(u);

Expected behavior: No error

Actual behavior: Argument of type "A"|"B" is not assignable to type "B"

Ideally, TypeScript should detect that there is an overload for each variant of the union type and thus accept the union type as an argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0