export type Result = ResultOk | ResultError; export declare namespace Result { function ok(value: T): ResultOk; function error(value: E): ResultError; function fromString(errorMessage: string): ResultError; function tryWith(f: () => T): Result; function tryWithAsync(f: () => Promise): Promise>; } /** * To instantiate a ResultOk, use `Result.ok(value)`. * To instantiate a ResultError, use `Result.error(value)`. */ declare class ResultOk { readonly val: T; constructor(val: T); map(f: (value: T) => U): ResultOk; mapError(_f: (error: never) => E2): ResultOk; flatMap(f: (value: T) => Result): Result; /** * Returns the contained ok value. * @throws if this is an error (which is impossible for `ResultOk`, * but provided for use on the `Result` union type). */ unwrap(): T; /** * Returns the contained ok value, or the provided default if this * is an error. */ unwrapOr(_defaultValue: T): T; isOk(): this is ResultOk; isError(): this is ResultError; } /** * To instantiate a ResultOk, use `Result.ok(value)`. * To instantiate a ResultError, use `Result.error(value)`. */ declare class ResultError { readonly err: E; constructor(err: E); map(_f: (value: never) => U): ResultError; mapError(f: (error: E) => E2): ResultError; flatMap(_f: (value: never) => Result): ResultError; /** * Always throws since this is an error result. * @throws The contained error value (wrapped in Error if not already one). */ unwrap(): never; /** * Returns the provided default value since this is an error. */ unwrapOr(defaultValue: T): T; isOk(): this is ResultOk; isError(): this is ResultError; } export {}; //# sourceMappingURL=result.d.ts.map