Skip to content

Suggestion: Allow array of > 10 values in argument of Promise.all() and Promise.race() #22469

Closed
@davidjenkins

Description

@davidjenkins

Currently, Promise.all() and Promise.race() both have signatures like this:

all<T1>(values: [T1 | PromiseLike<T1>]): Promise<[T1]>;
// ...
all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;

While this is suitable in most cases, occasionally there is a need (or preference) to wait on the retrieval of several (10+) dependencies and then access them all within a single block.

Workarounds for Promise.all() certainly exist (i.e. splitting into multiple Promise.all() calls) - but code can become unnecessarily complex. Workarounds for Promise.race() are not as easy.

Since actual implementations of Promise.all() and Promise.race() are boundless, it would be helpful if lib.es2015.promise.d.ts reflected a wider range of plausible use cases.

Proposed solution:
Add overloads to lib.es2015.promise.d.ts - using the pattern it already uses today - to support ~20 items instead of ~10.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already createdFix AvailableA PR has been opened for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions