/** * Result type for error handling without exceptions. * Use at service boundaries and for operations that can fail. */ type Result = Readonly<{ success: true; data: T; }> | Readonly<{ success: false; error: E; }>; /** * Unwraps a result, throwing if it's an error. */ declare function unwrap(result: Result): T; /** * Type guard to check if result is successful. * * Narrows to the `Readonly<{...}>` success arm so that an early-return on the * negative branch (`if (isErr(x)) return; x.data`) leaves the success arm * reachable — the union members are themselves `Readonly`, so a mutable * predicate target would subtract nothing and break narrowing for callers. */ declare function isOk(result: Result): result is Readonly<{ success: true; data: T; }>; /** * Type guard to check if result is an error. See {@link isOk} for why the * predicate narrows to the `Readonly<{...}>` arm. */ declare function isErr(result: Result): result is Readonly<{ success: false; error: E; }>; export { type Result as R, isOk as a, isErr as i, unwrap as u };