Skip to content

Conversation

@dubzzz
Copy link

Following the feature - Mapped tuple types #25947 - it is now possible to have better typings for Promise.race.

@RyanCavanaughRyanCavanaugh added this to the TypeScript 3.2 milestone Sep 18, 2018
@dubzzzdubzzz closed this Sep 19, 2018
@dubzzz
Copy link
Author

Actually I closed the issue because I thought that race<T>(values: (T | PromiseLike<T>)[]): Promise<T> might already handle such infinite number of parameters but my try on the playground show the contrary so I re-open the PR.

For the moment, the following code is invalid:

constwaitingFirst: Promise<number|string>=Promise.race([Promise.resolve(1),Promise.resolve(1),Promise.resolve(1),Promise.resolve(1),Promise.resolve(1),Promise.resolve("e"),Promise.resolve(1),Promise.resolve(1),Promise.resolve(1),Promise.resolve("e"),Promise.resolve(1)]);

But it should be fixed by this PR.

@dubzzzdubzzz reopened this Sep 19, 2018
@rbuckton
Copy link
Contributor

Wouldn't this be cleaner?

interfacePromiseConstructor{// arrayrace<T>(values: T[]): Promise<TextendsPromiseLike<infer U> ? U : T>;// iterablerace<T>(values: Iterable<T>): Promise<TextendsPromiseLike<infer U> ? U : T>;}

@dubzzz
Copy link
Author

@rbuckton Indeed it would be cleaner. I am updating the commit accordingly

@Jessidhia
Copy link

Isn't array already Iterable? 🤔

@rbuckton
Copy link
Contributor

@Kovensky: It is, but we split the definition between different lib files based on how much of ES2015 your host supports.

@dubzzz
Copy link
Author

@rbuckton Do I need to adapt something in this PR?

@rbuckton
Copy link
Contributor

@typescript-bot test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 6, 2019

Heya @rbuckton, I've started to run the extended test suite on this PR at f6f4f5d. You can monitor the build here. It should now contribute to this PR's status checks.

@rbuckton
Copy link
Contributor

This change may be causing a compiler crash in our RWC suite. We are investigating.

@dubzzz
Copy link
Author

Please let me know when you get more details about the failure ;)

@rbuckton
Copy link
Contributor

Unfortunately, conditional types tend to result in higher memory usage in the compiler. One of our RWC test suites is crashing due to running out of memory as a result of this change. I will continue to investigate, but unfortunately will be out of the office next week. If this is something I am unable to address before Friday, I will continue to investigate when I return to the office.

@RyanCavanaugh
Copy link
Member

@dubzzz in an attempt to get this branch rebased with master, I broke everything (long story). Opened a new PR at #31117

@dubzzzdubzzz mentioned this pull request Jun 13, 2020
@microsoftmicrosoft locked as resolved and limited conversation to collaborators Oct 21, 2025
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@dubzzz@rbuckton@Jessidhia@typescript-bot@RyanCavanaugh@DanielRosenwasser