-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript
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:
hongaar, Artuar, guilhermetod, turisap, polomsky and 38 moredaniel-nagy, mbelsky, ExE-Boss, epicmet and bfontaine
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript