API reference@evolu/commonResult › getOk

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

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

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 { getOk, ok, type Result } from "@evolu/common";

const getCount = (): Result<number> => ok(2);
const count = getOk(getCount());
expectTypeOf(count).toEqualTypeOf<number>();
expect(count).toBe(2);