Closed
Description
π Search Terms
control flow analysis, unreachable code
π Version & Regression Information
Tested in 5.8.2
β― Playground Link
π» Code
function test(a: number | undefined): void {
if (true) {
return;
}
if (a !== undefined) {
const b: number = a;
console.log(b);
}
}
π Actual behavior
Type 'number | undefined' is not assignable to type 'number'.
Type 'undefined' is not assignable to type 'number'.
π Expected behavior
Code compiles without error.
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
No labels