Skip to content

narrowing in switch doesn't work with non-union types #16976

Description

classA{readonlykind='a';}typeU=A;// <-- supposed to be a single case uniondeclarevaru: U;declarefunctionnever(never: never): never;functionfn(){switch(u.kind){case'a': return1;default: returnnever(u);// <-- u expected to be never, actually is A}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions