UNPKG

dont-throw

Version:
7 lines (6 loc) 418 B
import { Result } from "./result"; type Fn<T> = () => T; type AsyncReturnType<T extends (...args: any) => PromiseLike<any>> = T extends (...args: any) => Promise<infer R> ? R : any; export declare function tryCatch(fn: Fn<never>): Result<never, unknown>; export declare function tryCatch<T>(fn: Fn<T>): T extends PromiseLike<unknown> ? Promise<Result<AsyncReturnType<Fn<T>>, unknown>> : Result<T, unknown>; export {};