Closed
Description
π Search Terms
switch, fallthrough
π Version & Regression Information
- This is a crash No
- This changed between versions 5.2 and 5.3
β― Playground Link
π» Code
type foo = 'a' | 'b' | 'c'
const f = 'a' as foo
switch(true) {
case f === 'a':
case f === 'b':
console.log(f)
// ^? 'b'
break
default:
console.log(f)
// ^? 'a' | 'b' | 'c'
}
π Actual behavior
The fallthrough case has wrong type b
.
The default case is not narrowed.
π Expected behavior
In the fallthrough the type should be a union of a | b
.
The default case should be c
.
Additional information about the issue
Related to 70b7de1