Documentation
    Preparing search index...

    Variable Result

    Result: {
        Err: <T, E>(error?: E) => Result<T, E>;
        isErr: <T, E>(result: Result<T, E>) => result is { error: E; ok: false };
        isOk: <T, E>(result: Result<T, E>) => result is { ok: true; value: T };
        isUnknownError: <T, E>(
            result: Result<T, E>,
        ) => result is { error: never; ok: false };
        Ok: <T, E>(value?: T) => Result<T, E>;
    }

    Type declaration

    • Err: <T, E>(error?: E) => Result<T, E>

      Create a Result that contains an error.

      Result.Err('error') // => { ok: false, error: 'error' }
      Result.Err() // => { ok: false, error: undefined }
    • isErr: <T, E>(result: Result<T, E>) => result is { error: E; ok: false }

      Check if a Result is an error.

    • isOk: <T, E>(result: Result<T, E>) => result is { ok: true; value: T }

      Check if a Result is OK.

    • isUnknownError: <T, E>(result: Result<T, E>) => result is { error: never; ok: false }

      Check if a Result is an unknown error (error field is undefined).

    • Ok: <T, E>(value?: T) => Result<T, E>

      Create a Result that contains a value.

      Result.Ok(42) // => { ok: true, value: 42 }
      Result.Ok() // => { ok: true, value: undefined }