method Result.isOk
Result.isOk<T, E extends BaseError>(result: Result<T, E>): result is Result<T, never>

Type guard to check if a value is an Ok Result.

Examples

Example 1

const result = Result.ok(42);
if (Result.isOk(result)) {
  // TypeScript knows result is Ok<number> here
}

Type Parameters

The type of the success value

E extends BaseError

The type of the error

Parameters

result: Result<T, E>

The Result to check

Return Type

result is Result<T, never>

True if the result is Ok, false otherwise

Usage

import { Result } from "result/mod.ts";