Skip to content

Type guard failures that become an intersection type #9859

Description

TypeScript Version: 2.0.0

Code

classA<T>{private_: T;}classB<T>{private_: T;}functionf(){varo: A<void>|B<void>=newB<void>();if(oinstanceofA)returno;// B<void> & A<any>, should be A<void>}

Expected behavior:

A type of o narrowed by type guard is A<void>.

Actual behavior:

A type of o narrowed by type guard is B<void> & A<any>.

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