-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Description
π Search Terms
discriminated union, switch
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about switch
β― Playground Link
π» Code
type Foo = { id: 'foo', data: 'bar' }
const foo: Foo = { id: 'foo', data: 'bar' }
switch (foo.id) {
case 'foo': { console.log('match') }
default: throw new Error("No match", { cause: foo satisfies never })
// ^^^^^^^^^
}π Actual behavior
Despite expecting the value to be of type never, it retains its original type.
π Expected behavior
The value in the default branch should be typed as never.
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
No labels