-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Fix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do this
Milestone
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
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Fix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do this