-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Weaken the definition of PromiseLike to allow 'T | awaited T' #37570
Conversation
@typescript-bot perf test |
Heya @rbuckton, I've started to run the perf test suite on this PR at ed49c32. You can monitor the build here. Update: The results are in! |
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
@rbuckton Here they are:Comparison Report - master..37570
System
Hosts
Scenarios
|
Can you explain some actual problems caused by the current correct definition? If you weaken the definition, I have to define my correct PromiseLike interface to strictly check the types. |
The user tests look pretty bad with this change. But I don't know what they were like before. Have they been this broken since first merging |
See also my first fix falsandtru/spica@c569afd We need |
Closing in favor of #37610 while we continue to investigate the impact of |
This weakens the definition of
PromiseLike
to allow thevalue
argument to beT | awaited T
. This is necessary becausePromiseLike
represents any promise-like value that can be adopted by a nativePromise
. This includes Promise definitions that are not Promise/A+ compatible, such as JQuery'sDeferred
. As a result, thevalue
argument may or not be recursively unwrapped depending on the implementation.This is intended to work in conjunction with DefinitelyTyped/DefinitelyTyped#43337 to address errors in DefinitelyTyped and other projects following the introduction of
awaited
.NOTE: this means that unlike with
Promise
, aPromiseLike<Promise<number>>
will not be assignable toPromiseLike<number>
, as the value may not be recursively unwrapped and therefore we cannot guarantee they are relatable.