Closed
Description
Sorry if this has been reported before, I tried my best searching for similar issues. I guess this is more of a "Is this 'As Designed'?" question as opposed to a bug report. It's caught me off guard a few times and thought I'd mention it at least.
TypeScript Version: 3.1.1
Search Terms: Type check, null, undefined
Code
// Example 1
const myNumber = 32;
if (myNumber === undefined) {
console.log('This will never run');
}
// Example 2
const test: number | null = null;
if (test === undefined) {
console.log('Woof');
} else {
console.log('Meow');
}
Expected behavior:
A warning on line 2 in both examples that myNumber
/test
will never be undefined. (Or line 3 that the code is unreachable).
Actual behavior:
Code compiles fine without issue.
Related Issues: No