Infers the error type of a result.
Works on a Result, a ResultAsync, and on functions returning either, such as a ResultFn or a ResultAsyncFn. A result that can never fail, such as a ResultOk, has the error type never.
never
The result, async result or result-returning function.
async function fetchUser(id: string): ResultAsync<User, "NOT_FOUND" | "NETWORK"> { // ...}type FetchUserError = InferErr<typeof fetchUser>; // "NOT_FOUND" | "NETWORK" Copy
async function fetchUser(id: string): ResultAsync<User, "NOT_FOUND" | "NETWORK"> { // ...}type FetchUserError = InferErr<typeof fetchUser>; // "NOT_FOUND" | "NETWORK"
Infers the error type of a result.
Works on a Result, a ResultAsync, and on functions returning either, such as a ResultFn or a ResultAsyncFn. A result that can never fail, such as a ResultOk, has the error type
never.