Skip to content

Use variadic tuples in Promise.all #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

tom-sherman
Copy link
Owner

Fixes microsoft#39788

I've changed the Promise.all function to use variadic tuples. Example:

declare const foo: Promise<string>;
declare const bar: Promise<number>[];

declare interface PromiseConstructor {
    all<T extends readonly unknown[]>(values: [...T]): { [P in keyof T]: T[P] extends Promise<infer U> ? U : never }
}

async function m() {
    const p = await Promise.all([
        foo,
        ...bar
    ])
}

Playground link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4.0: Cannot use variadic tuples in Promise.all
1 participant