ts-data-forge
    Preparing search index...
    • Checks if a Result is Result.Ok. Acts as a type guard, narrowing the type to the success variant.

      This function is essential for type-safe Result handling, allowing TypeScript to understand that subsequent operations will work with the success value rather than the error value.

      Type Parameters

      • R extends Result.Base

        The Result.Base type to check.

      Parameters

      • result: R

        The Result to check.

      Returns result is NarrowToOk<R>

      true if the Result is Result.Ok, otherwise false.

      const operation = Result.ok(3);
      const failure = Result.err('error');

      if (Result.isOk(operation)) {
      const value: number = operation.value;
      assert(value === 3);
      }

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