<A>(_: never): AMarks an impossible branch by accepting a never value and returning any
type.
When to use
Use when you need a return value in a branch that exhaustive checks prove cannot be reached.
Gotchas
Calling absurd throws, because a value of type never should be
impossible at runtime.
Example (Handling impossible values)
import { absurd } from "effect"
const handleNever = (value: never) => {
return absurd(value) // This will throw an error if called
}utility types
Source effect/Function.ts:5183 lines
export const const absurd: <A>(_: never) => AMarks an impossible branch by accepting a never value and returning any
type.
When to use
Use when you need a return value in a branch that exhaustive checks prove
cannot be reached.
Gotchas
Calling absurd throws, because a value of type never should be
impossible at runtime.
Example (Handling impossible values)
import { absurd } from "effect"
const handleNever = (value: never) => {
return absurd(value) // This will throw an error if called
}
absurd = <function (type parameter) A in <A>(_: never): AA>(_: never_: never): function (type parameter) A in <A>(_: never): AA => {
throw new var Error: ErrorConstructor
new (message?: string, options?: ErrorOptions) => Error (+1 overload)
Error("Called `absurd` function which should be uncallable")
}Referenced by 1 symbols