clean-jsdoc-theme TypeDoc APIv0.0.0

assertNever

assertNever(x: never): never

Source: 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)
  }
}