Closed
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.