🔧Result
type Result<T, E = unknown> = Ok<T> | Err<E, T>
Result
accepts 2 type parameters, T
is the ok value type, E
is the error value type.
Ok
and Err
are 2 internal types, you shouldn't use them directly.
Example
You can create a Result
type by calling 2 functions ok
and err
.
const r1 = ok(1)
// ^? const r1: Result<number, never>
const r2 = err(1)
// ^? const r2: Result<unknown, number>
Last updated