Type Alias: InferSuccess<T>
InferSuccess<T
> = [T
] extends [(...args
) => ResultMaybeAsync
<infer U, any
>] ? U
: [T
] extends [ResultMaybeAsync
<infer U, any
>] ? U
: never
Defined in: result.ts:170
Infers the Success value type T
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 SuccessValue = Result.InferSuccess<R>; // number
import { Result } from '@praha/byethrow';
const fn = () => Promise.resolve({ type: 'Success', value: 123 } as const);
type SuccessValue = Result.InferSuccess<typeof fn>; // number