error.ts

Declarations
#

2 declarations

view source

unreachable
#

error.ts view source

(value: never, message?: string | undefined): asserts value is never

Beyond terseness, this is useful because throw is not an expression, and therefore can't be used in places like Svelte markup without a workaround, at least until this proposal is accepted and widely available: https://github.com/tc39/proposal-throw-expressions

value

type never

message?

type string | undefined
optional

returns

void

UnreachableError
#

error.ts view source

Error for asserting unreachable code paths in TypeScript. Useful for exhaustive matching.

inheritance

extends:
  • Error

constructor

type new (value: never, message?: string, options?: ErrorOptions | undefined): UnreachableError

value
type never
message
type string
default `Unreachable case: ${value}`
options?
type ErrorOptions | undefined
optional