Add variadic tuple overload to Promise.all#39796
Conversation
|
@typescript-bot test this |
|
Heya @ahejlsberg, I've started to run the extended test suite on this PR at 00fa5b8. You can monitor the build here. |
|
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 00fa5b8. You can monitor the build here. |
|
Heya @ahejlsberg, I've started to run the parallelized community code test suite on this PR at 00fa5b8. You can monitor the build here. |
|
@typescript-bot user test this |
|
Heya @ahejlsberg, I've started to run the parallelized community code test suite on this PR at 00fa5b8. You can monitor the build here. |
|
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
|
@rbuckton Interesting that this doesn't seem to break VSCode. In fact, best I can tell, none of the differences in the user tests appear to be caused by adding the extra overload. |
|
@typescript-bot test this |
|
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 4f5b329. You can monitor the build here. |
|
Heya @ahejlsberg, I've started to run the parallelized community code test suite on this PR at 4f5b329. You can monitor the build here. |
|
Heya @ahejlsberg, I've started to run the extended test suite on this PR at 4f5b329. You can monitor the build here. |
|
Latest commit removes the old overloads. This is a breaking change for calls with explicit type arguments, but it may still be worth it for the simplicity and improvement in error reporting that it brings. Re-running tests to see the effects. |
|
I'm still very wary of Basically, I'd also looked into adding type Awaited<T> =
T extends { then(onfulfilled: (value: infer U) => any): any; } ? U :
T extends { then(...args: any[]): any; } ? never :
T;This definition represented the minimal case that was consistent with declare const p: { then(): void };
async function f() {
await p; // Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member.
} |
|
Ah, disregard the comment about We could theoretically bake in a few levels of nesting. Its fairly trivial to result in type Awaited<T> =
T extends undefined ? T :
T extends PromiseLike<PromiseLike<infer U>> ? U :
T extends PromiseLike<infer U> ? U :
U;While more verbose, it does handle both the common cases ( |
| @@ -1,3 +1,5 @@ | |||
| type Awaited<T> = T extends undefined ? T : T extends PromiseLike<infer U> ? U : T; | |||
There was a problem hiding this comment.
I would propose we move this to es5.d.ts so that it sits alongside PromiseLike, as it has no dependency on Promise directly.
|
This can probably be reevaluated now that #45350 has been merged. |
|
This experiment is pretty old, so I'm going to close it to reduce the number of open PRs. |
Experiment for now. Similar to #39336, but with a different overload definition.