Exhaustiveness check for discriminated unions.
Use in the default case of switch statements to ensure all cases are handled.
TypeScript will report a compile-time error if a case is missing.
Parameters
value: never
The value that should be of type never if all cases are handled
Optionalmessage: string
Optional custom error message
Returns never
Never returns - always throws
Throws
Always throws with the unhandled value
Example
typeShape = { kind: 'circle'; radius: number } | { kind: 'square'; size: number };
Exhaustiveness check for discriminated unions. Use in the default case of switch statements to ensure all cases are handled. TypeScript will report a compile-time error if a case is missing.