API reference@evolu/commonResult › getOk

function getOk<T>(result: Result<T>): T;

Defined in: packages/common/src/Result.ts:554

Gets the value from a Result whose error type is never.

This is useful when the type system guarantees the result cannot fail (for example Result<T, never>), avoiding impossible if (!result.ok) branches at call sites.

Example

import { assertEqual, assertType, getOk, ok, type Result } from "@evolu/common";

const getCount = (): Result<number> => ok(2);
const count = getOk(getCount());
assertType<number, typeof count>();
assertEqual(count, 2);