- Notifications
You must be signed in to change notification settings - Fork13.2k
Adds 'Awaited' type alias and updates to Promise.all/race/allSettled/any#45350
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
rbuckton commentedAug 25, 2021
@typescript-bot perf test |
typescript-bot commentedAug 25, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
typescript-bot commentedAug 25, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Heya@rbuckton, I've started to run the perf test suite on this PR at46ce88c. You can monitor the buildhere. Update:The results are in! |
typescript-bot commentedAug 25, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
typescript-bot commentedAug 25, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
typescript-bot commentedAug 25, 2021
The user suite test run you requested has finished andfailed. I've opened aPR with the baseline diff from master. |
rbuckton commentedAug 25, 2021
Interesting outcomes from the rwc tests:
|
typescript-bot commentedAug 28, 2021
@rbuckton Here they are:Comparison Report - main..45350
System
Hosts
Scenarios
Developer Information: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rbuckton commentedAug 30, 2021
The OOM in Prettier doesn't seem to be related to this change, as I'm seeing it in other unrelated PRs as well. |
rbuckton commentedAug 30, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Notes from design meeting:
|
rbuckton commentedSep 3, 2021
I investigated whether having |
rbuckton commentedSep 3, 2021
@typescript-bot perf test |
typescript-bot commentedSep 3, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
typescript-bot commentedSep 9, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hey@andrewbranch, I've packed this intoan installable tgz. You can install it for testing by referencing it in your and then running There is also a playgroundfor this build and annpm module you can use via |
| T :// argument was not an object | ||
| T;// non-thenable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I believe that these comments are swapped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Apparently so. I will push up a small fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Fixed by#45918
frigus02 commentedSep 28, 2021
I did a quick search for To check usages of |
julienavert commentedNov 26, 2021
Hello everyone, Not sure if this is the correct place to bring this up but the For reference, here is what /** * Recursively unwraps the "awaited type" of a type. Non-promise "thenables" should resolve to `never`. This emulates the behavior of `await`. */typeAwaited<T>=Textendsnull|undefined ?T :// special case for `null | undefined` when not in `--strictNullChecks` modeTextendsobject&{then(onfulfilled: inferF):any} ?// `await` only unwraps object types with a callable `then`. Non-object types are not unwrappedFextends((value: inferV)=>any) ?// if the argument to `then` is callable, extracts the argumentAwaited<V> :// recursively unwrap the valuenever :// the argument to `then` was not callableT;// non-object or non-thenable The problem is that we have a custom Promise class ( Our publicthen<TResult1=T,TResult2=never>(onfulfilled?:((value:T,abortController:AbortController)=>TResult1|PromiseLike<TResult1>)|undefined|null,onrejected?:((reason:any)=>TResult2|PromiseLike<TResult2>)|undefined|null):AbortablePromise<TResult1|TResult2>; So Hence, Would it be possible to make the type condition more flexible in |
wbt commentedAug 10, 2022
It would be helpful to add some documentation about this on theUtility types page, not just in the 4.5 release notes that aren't part of the docs search. |
This adds an
Awaited<T>type alias that supports the following capabilities:PromiseLike(to avoid issues with augmentation/assignability)nevernullandundefinedin non-strictNullChecks modeThis also adds overloads to
Promise.all,Promise.race,Promise.allSettled, andPromise.anyto leverageAwaited<T>.Supersedes#33707, thanks@jablko for your prior work on this.
Fixes#27711
Fixes#22469
Fixes#28427
Fixes#30390
Fixes#31722
Fixes#33559
Fixes#33562
Fixes#33752
Fixes#34924
Fixes#34937
Fixes#35136
Fixes#35258