/** * @fileoverview Result type for functional error handling without exceptions. */ /** * Result type representing either success (Ok) or failure (Err). */ export type Result = Ok | Err; /** * Successful result containing a value. */ export declare class Ok { readonly kind: "ok"; readonly value: T; constructor(value: T); /** * Chain another result-returning operation. */ andThen(fn: (_value: T) => Result): Result; /** * Check if this result is an error. */ isErr(): boolean; /** * Check if this result is successful. */ isOk(): this is Ok; /** * Transform the success value. */ map(fn: (_value: T) => U): Result; /** * Transform the error (no-op for Ok). */ mapErr(_fn: (_error: never) => F): Result; /** * Return this result or the other if error (no-op for Ok). */ orElse(_fn: (_error: never) => Result): Result; /** * Get the success value or throw if error. */ unwrap(): T; /** * Get the success value or return default if error. */ unwrapOr(_defaultValue: T): T; /** * Get the success value or compute from error if error. */ unwrapOrElse(_fn: (_error: never) => T): T; } /** * Error result containing an error. */ export declare class Err { readonly kind: "err"; readonly error: E; constructor(error: E); /** * Chain another result-returning operation (no-op for Err). */ andThen(_fn: (_value: never) => Result): Result; /** * Check if this result is an error. */ isErr(): this is Err; /** * Check if this result is successful. */ isOk(): boolean; /** * Transform the success value (no-op for Err). */ map(_fn: (_value: never) => U): Result; /** * Transform the error. */ mapErr(fn: (_error: E) => F): Result; /** * Return this result or the other if error. */ orElse(fn: (_error: E) => Result): Result; /** * Get the success value or throw if error. */ unwrap(): never; /** * Get the success value or return default if error. */ unwrapOr(defaultValue: T): T; /** * Get the success value or compute from error if error. */ unwrapOrElse(fn: (_error: E) => T): T; } /** * Create a successful result. */ export declare function ok(value: T): Ok; /** * Create an error result. */ export declare function err(error: E): Err; /** * Utility functions for working with Results. */ export declare const ResultUtils: { /** * Convert all Results to Ok values or return first error. */ all[]>(results: T): Result<{ [K in keyof T]: T[K] extends Result ? U : never; }, T[number] extends Result ? E : never>; /** * Return the first Ok result or the last error. * Returns an error result if the input array is empty. */ any[]>(results: T): T[number]; /** * Create an error result. */ err: typeof err; /** * Wrap a function that might throw into a Result. */ from(fn: () => T): Result; /** * Create a successful result. */ ok: typeof ok; };