Type Alias: ResultFor<R, T, E>

ResultFor<R, T, E> = true extends HasPromise<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.

Type Parameters

R

R

The reference type to inspect for a Promise.

T

T

The type of the Success value.

E

E

The type of the Failure value.

Examples

import { Result } from '@praha/byethrow';

type R = Result.ResultAsync<number, string>;
type Output = Result.ResultFor<R, number, string>; // Result.ResultAsync<number, string>
import { Result } from '@praha/byethrow';

type R = Result.Result<number, string>;
type Output = Result.ResultFor<R, number, string>; // Result.Result<number, string>