Closed
Description
TypeScript Version: 3.8.3 Nightly
Search Terms:
- switch statement
- switch (true)
Code
let x: string | undefined;
if (typeof x !== 'undefined') {
x.trim(); // works as expected
}
switch (true) {
case typeof x !== 'undefined':
x.trim(); // thinks x is potentially undefined
}
Expected behavior:
Narrowing types should work inside the case
.
Actual behavior:
Any assertion in case
seems to be disregarded
Related Issues: