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.
T
A ResultMaybeAsync type or a function returning it.
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 ErrorValue = string ErrorValue = import Result Result .type InferFailure<T> = [T] extends [(...args: any[]) => Result.ResultMaybeAsync<any, infer U>] ? U : [T] extends [Result.ResultMaybeAsync<any, infer U>] ? U : neverInfers the
Failure
value type E from a Result or a function returning a Result.
InferFailure <type R = Result.Success<number> | Result.Failure<string> R >; // stringimport { import Result Result } from '@praha/byethrow';
const const fn: () => Promise<{
readonly type: "Failure";
readonly error: Error;
}>
fn = () => var Promise: PromiseConstructorRepresents the completion of an asynchronous operation
Promise .PromiseConstructor.resolve<{
readonly type: "Failure";
readonly error: Error;
}>(value: {
readonly type: "Failure";
readonly error: Error;
}): Promise<{
readonly type: "Failure";
readonly error: Error;
}> (+2 overloads)
Creates a new resolved promise for the provided value.
resolve ({ type: "Failure" type : 'Failure', error: Error error : new var Error: ErrorConstructor
new (message?: string, options?: ErrorOptions) => Error (+1 overload)
Error () } as type const = {
readonly type: "Failure";
readonly error: Error;
}
const );
type type ErrorValue = Error ErrorValue = import Result Result .type InferFailure<T> = [T] extends [(...args: any[]) => Result.ResultMaybeAsync<any, infer U>] ? U : [T] extends [Result.ResultMaybeAsync<any, infer U>] ? U : neverInfers the
Failure
value type E from a Result or a function returning a Result.
InferFailure <typeof const fn: () => Promise<{
readonly type: "Failure";
readonly error: Error;
}>
fn >; // Error