Question · JavaScript and TypeScript course · Module 7: Advanced TypeScript
Exhaustive Check with never
What is the purpose of the never type in the default clause of a switch statement when handling a discriminated union?
Answer options
- Guarantees that all union variants have been handled - if you miss a variant, TypeScript will report an error
- Prevents the default switch branch from executing
- Automatically converts a type to null
- Creates a new union variant for error handling
You can check the correct answer by solving this task in the CodeWorlds game.