Skip to content
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

Use variadic tuples in Promise.all #39789

Closed

Conversation

tom-sherman
Copy link

Fixes #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

@typescript-bot
Copy link
Collaborator

It looks like you've sent a pull request to update our 'lib' files. These files aren't meant to be edited by hand, as they consist of last-known good states of the compiler and are generated from 'src'. Unless this is necessary, consider closing the pull request and sending a separate PR to update 'src'.

@typescript-bot typescript-bot added lib update PR modifies files in the `lib` folder For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Jul 28, 2020
@ghost
Copy link

ghost commented Jul 28, 2020

CLA assistant check
All CLA requirements met.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug lib update PR modifies files in the `lib` folder
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4.0: Cannot use variadic tuples in Promise.all
2 participants