Skip to content

Wrong unification of union when the alternative types have some intersection. #11403

Closed
@sledorze

Description

@sledorze

TypeScript Version: 2.0.3

Code

function foo<A, B>(c:boolean, a:A, ab:A & B) { // foo return type is inferred to A instead of A | (A & B)
    return c ? a : ab; 
}

Expected behavior:

foo return type is inferred to A | (A & B)

Actual behavior:

foo return type is inferred to A

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