Skip to main content

MaybePromise

@ts-rust/std


@ts-rust/std / Types / MaybePromise

Type Alias: MaybePromise<T>

type MaybePromise<T> = T | Promise<T>;

Defined in: packages/std/src/types.ts:190

Represents either a value of type T or a Promise resolving to T.

The MaybePromise type provides flexibility when working with both synchronous and asynchronous values in a unified way. It allows functions and interfaces to accept either immediate values or promises without needing separate implementations, simplifying API design and improving interoperability between synchronous and asynchronous code.

The T type parameter represents the actual value type, whether provided directly or eventually resolved from a Promise.

Type Parameters

Type Parameter

T