ResultFor<
R,T,E> =trueextendsHasPromise<R> ?ResultAsync<T,E> :Result<T,E>
Defined in: result.ts:145
Resolves to the appropriate Result type (sync or async) based on the input type.
Typically used to conditionally infer return types based on whether the original computation was async.
R
The reference type to inspect for a Promise.
T
The type of the Success value.
E
The type of the Failure value.
import { import Result Result } from '@praha/byethrow';
type type R = Promise<Result.Result<number, string>> R = import Result Result .type ResultAsync<T, E> = Promise<Result.Result<T, E>>An asynchronous variant of
Result
, wrapped in a Promise.
ResultAsync <number, string>;
type type Output = Promise<Result.Result<number, string>> Output = import Result Result .type ResultFor<R, T, E> = true extends HasPromise<R> ? Result.ResultAsync<T, E> : Result.Result<T, E>Resolves to the appropriate Result type (sync or async) based on the input type.
Typically used to conditionally infer return types based on whether the original computation was async.
ResultFor <type R = Promise<Result.Result<number, string>> R , number, string>; // Result.ResultAsync<number, string>import { import Result Result } from '@praha/byethrow';
type type R = Result.Success<number> | Result.Failure<string> R = import Result Result .type Result<T, E> = Result.Success<T> | Result.Failure<E>A union type representing either a success or a failure.
Result <number, string>;
type type Output = Result.Success<number> | Result.Failure<string> Output = import Result Result .type ResultFor<R, T, E> = true extends HasPromise<R> ? Result.ResultAsync<T, E> : Result.Result<T, E>Resolves to the appropriate Result type (sync or async) based on the input type.
Typically used to conditionally infer return types based on whether the original computation was async.
ResultFor <type R = Result.Success<number> | Result.Failure<string> R , number, string>; // Result.Result<number, string>