-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
The code below works in TS 3.0.
TypeScript Version: 3.2.1.0
Search Terms: is:issue 3.2 Partial
Code
declare function never(value: never): never;
const enum BarEnum {
bar1 = 1,
bar2 = 2,
}
type UnionOfBar = TypeBar1 | TypeBar2;
type TypeBar1 = {
type: BarEnum.bar1;
};
type TypeBar2 = {
type: BarEnum.bar2;
};
const value: Partial<UnionOfBar> = {} as any;
if (value.type !== undefined) {
switch (value.type) {
case BarEnum.bar1: break;
case BarEnum.bar2: break;
default: never(value.type); // Error: Type 'undefined' is not assignable to parameter of type 'never'
}
}Expected behavior:
No compiler error
Actual behavior:
Type 'undefined' is not assignable to parameter of type 'never'
Related Issues:
#28748
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue