Skip to content

@kaelyx/ts-kit / result / ok

Function: ok() ​

ok<T>(value): Result<T, never>

Defined in: result/ok/ok.ts:19

Creates a successful Result that holds the given value.

Type Parameters ​

T ​

T

Parameters ​

value ​

T

The value to hold. Falsy values such as undefined, '' or 0 are kept as they are.

Returns ​

Result<T, never>

A Result with ok: true and the value in the value property.

Example ​

ts
ok(42) // { ok: true, value: 42 }
ok({ name: 'John' }) // { ok: true, value: { name: 'John' } }