ts-fortress
    Preparing search index...

    Variable okConst

    ok: <const S>(value: S) => Ok<S>

    Creates a Result.Ok containing the given success value.

    Use this constructor when an operation succeeds and you want to wrap the successful result in a Result type for consistent error handling.

    Type Declaration

      • <const S>(value: S): Ok<S>
      • Type Parameters

        • const S

          The type of the success value.

        Parameters

        • value: S

          The success value.

        Returns Ok<S>

        A Result.Ok<S> containing the value.

    const success = Result.ok({ id: 1 });

    const failure = Result.err(new Error('missing data'));

    assert.deepStrictEqual(success, {
    $$tag: 'ts-data-forge::Result.ok',
    value: { id: 1 },
    });

    assert.isTrue(Result.isErr(failure));