promiseAll
The promiseAll() function resolves all values from a tuple or an iterable, while preserving precise tuple typing for tuple inputs.
Interactive example
Syntax
typescript
function promiseAll<
const GenericInput extends AnyTuple | Iterable<unknown>
>(
input: GenericInput,
): GenericInput extends AnyTuple
? Promise<{ -readonly [Prop in keyof GenericInput]: Awaited<GenericInput[Prop]>; }>
: GenericInput extends Iterable<infer InferredValue>
? Promise<Awaited<InferredValue>>[]
: never;Parameters
input: Tuple or iterable containing promises, direct values, or both.
Return value
- If
inputis a tuple, returns aPromiseof a resolved tuple with preserved structure. - If
inputis an iterable, returns the resolvedPromise.all(...)result typed from iterable items.
See also
callThen- Applies a callback on a sync or async valuepromiseObject- Resolves an object of promisesasyncPipe- Chains asynchronous transformations
