Infers the value type of a result.
Works on a Result, a ResultAsync, and on functions returning either, such as a ResultFn or a ResultAsyncFn. Promises are unwrapped, so the value type of an async result is the resolved value.
The result, async result or result-returning function.
const safeParse = fromThrowable((raw: string): Config => JSON.parse(raw));type Parsed = InferOk<typeof safeParse>; // Configtype Fetched = InferOk<ResultAsync<Response, Error>>; // Response Copy
const safeParse = fromThrowable((raw: string): Config => JSON.parse(raw));type Parsed = InferOk<typeof safeParse>; // Configtype Fetched = InferOk<ResultAsync<Response, Error>>; // Response
Infers the value type of a result.
Works on a Result, a ResultAsync, and on functions returning either, such as a ResultFn or a ResultAsyncFn. Promises are unwrapped, so the value type of an async result is the resolved value.