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