- Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
assuming my understanding it right: an extended union is a subset (subtype) of the original union
declarefunctionnever(never: never): never;typeX='A'|'B'|'C';voidfunctionfn<YextendsX>(y: Y): Y{switch(y){case'A': returny;case'B': returny;case'C': returny;default: returnnever(y);// <-- y expected to be never, actual Y}}same problem with objects
typeX={k: 'A'}|{k: 'B'}|{k: 'C'};voidfunctionfn<YextendsX>(y: Y): Y{switch(y.k){case'A': returny;case'B': returny;case'C': returny;default: returnnever(y);// <-- y expected to be never, actual Y}}masaeedu, krryan, mattmccutchen, marshall007, alexburner and 9 more
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue