Skip to content

Function: isOkResult()

isOkResult(value): value is Ok<any>

Defined in: index.ts:309

Type guard that checks if an unknown value is an Ok result. Unlike isOk, this accepts any unknown value and checks if it's a valid Ok result.

Parameters

value

unknown

The value to check

Returns

value is Ok<any>

True if the value is an Ok result, false otherwise

Example

typescript
if (isOkResult(value)) {
  // value is now typed as Ok
  console.log(value.data);
}