-
Notifications
You must be signed in to change notification settings - Fork 13k
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
declare function never(never: never): never;
type X = 'A' | 'B' | 'C';
void function fn<Y extends X>(y: Y): Y {
switch (y) {
case 'A': return y;
case 'B': return y;
case 'C': return y;
default: return never(y); // <-- y expected to be never, actual Y
}
}
same problem with objects
type X = { k: 'A' } | { k: 'B' } | { k: 'C' };
void function fn<Y extends X>(y: Y): Y {
switch (y.k) {
case 'A': return y;
case 'B': return y;
case 'C': return y;
default: return never(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