-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Control FlowThe issue relates to control flow analysisThe issue relates to control flow analysisFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
#35000 breaks activex-scripting on Definitely Typed because narrowing via assignment in switch no longer works:
type O = {
a: number,
b: number
}
type K = keyof O | 'c'
function f(o: O, k: K) {
switch(k) {
case 'c':
k = 'a'
}
k === 'c' // should have error here
return o[k] // and no error here
}Actual behavior:
No error on k === 'c' and error on o[k].
Using if (k === 'c') { instead of switch (k) { case 'c': works correctly.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Control FlowThe issue relates to control flow analysisThe issue relates to control flow analysisFix AvailableA PR has been opened for this issueA PR has been opened for this issue