Type Alias: InferFailure<T>
InferFailure<T
> = [T
] extends [(...args
) => ResultMaybeAsync
<any
, infer U>] ? U
: [T
] extends [ResultMaybeAsync
<any
, infer U>] ? U
: never
Defined in: result.ts:198
Infers the Failure value type E
from a Result or a function returning a Result.
Type Parameters
T
T
A ResultMaybeAsync type or a function returning it.
Examples
import { Result } from '@praha/byethrow';
type R = Result.Result<number, string>;
type ErrorValue = Result.InferFailure<R>; // string
import { Result } from '@praha/byethrow';
const fn = () => Promise.resolve({ type: 'Failure', error: new Error() } as const);
type ErrorValue = Result.InferFailure<typeof fn>; // Error