assertNever
assertNever(x: never): neverSource: common.ts:406
Utility type for exhaustive switch statements
Parameters
x(never) — Value that should be never
Returns
never
Example
CODE
type Status = 'pending' | 'active' | 'done'
function handleStatus(status: Status): string {
switch (status) {
case 'pending': return 'Waiting...'
case 'active': return 'In progress'
case 'done': return 'Completed'
default: return assertNever(status)
}
}