-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
Consider the following code
function test4(value: 1 | 2) {
let x: string;
switch (value) {
case 1: x = "one"; break;
case 2: x = "two"; break;
}
return x; //There is no path through the switch so x is alwayes assigned here.
}
Expected behavior:
The code should type check under --strict
Actual behavior:
Definite assignment does not realize that the switch is exhaustive and that all paths assign to x, so we get an error.
Checked with 2143a3f
SlurpTheo
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed