Closed
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