Add 'T | PromiseLike<T>' inference from awaited types - #37615
Add 'T | PromiseLike<T>' inference from awaited types#37615Ron Buckton (rbuckton) wants to merge 4 commits into
Conversation
|
TypeScript Bot (@typescript-bot) perf test |
|
Heya Ron Buckton (@rbuckton), I've started to run the parallelized community code test suite on this PR at 39eb820. You can monitor the build here. |
|
Heya Ron Buckton (@rbuckton), I've started to run the perf test suite on this PR at 39eb820. You can monitor the build here. Update: The results are in! |
|
Heya Ron Buckton (@rbuckton), I've started to run the extended test suite on this PR at 39eb820. You can monitor the build here. |
|
Heya Ron Buckton (@rbuckton), I've started to run the parallelized Definitely Typed test suite on this PR at 39eb820. 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. |
|
Ron Buckton (@rbuckton) Here they are:Comparison Report - master..37615
System
Hosts
Scenarios
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
39eb820 to
17517d5
Compare
|
then<ARD = never, AJD = never, ...>(
doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase<ARD, AJD, ...> | Thenable<ARD> | ARD,
failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase<ARF, ...> | Thenable<ARF> | ARF,
progressFilter: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase<ARP, ...> | Thenable<ANP> | ANP
): PromiseBase<ARD | ARF | ARP, AJD | AJF | AJP, ...>;
Upon further review this is not an issue with subtype reduction, but rather with this algorithm as it does not handle inference for the other type arguments to |
|
TypeScript Bot (@typescript-bot) perf test |
|
Heya Ron Buckton (@rbuckton), I've started to run the parallelized community code test suite on this PR at 3d2ac60. You can monitor the build here. |
|
Heya Ron Buckton (@rbuckton), I've started to run the extended test suite on this PR at 3d2ac60. You can monitor the build here. |
|
Heya Ron Buckton (@rbuckton), I've started to run the perf test suite on this PR at 3d2ac60. You can monitor the build here. Update: The results are in! |
|
Heya Ron Buckton (@rbuckton), I've started to run the parallelized Definitely Typed test suite on this PR at 3d2ac60. You can monitor the build here. |
|
Ron Buckton (@rbuckton) Here they are:Comparison Report - master..37615
System
Hosts
Scenarios
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3d2ac60 to
24b6d64
Compare
|
TypeScript Bot (@typescript-bot) run dt |
|
Heya Ron Buckton (@rbuckton), I've started to run the extended test suite on this PR at 24b6d64. You can monitor the build here. |
|
Heya Ron Buckton (@rbuckton), I've started to run the parallelized community code test suite on this PR at 24b6d64. You can monitor the build here. |
|
Heya Ron Buckton (@rbuckton), I've started to run the parallelized Definitely Typed test suite on this PR at 24b6d64. You can monitor the build here. |
|
TypeScript Bot (@typescript-bot) user test this |
|
Heya Ron Buckton (@rbuckton), I've started to run the parallelized community code test suite on this PR at de14792. You can monitor the build here. |
Anders Hejlsberg (@ahejlsberg), Wesley Wigham (@weswigham) I'd appreciate if you could take a look. |
|
Ron Buckton (@rbuckton) is this for 3.9 or 4.0? |
|
I was hoping for 3.9, as this was initially part of |
|
I think we should take this as an item in the design meeting to understand whether it goes in regardless of awaited. It's way too late in the game to add it to 3.9 IMO. |
|
Unfortunately, we never finished reviewing this PR. It is pretty old now, so I'm going to close it to reduce the number of open PRs. |
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
This re-introduces the
T | PromiseLike<T>inference heuristic previously added in theawaitedtype PR. This heuristic improves type inference for cases where we are inferring to a union consisting of a single type variableTand one or morePromise-like types whose "promised type" (i.e., the type of thevalueparameter to theonfulfilledcallback) is preciselyT. This primarily impacts inference for cases likePromise.resolveandPromise#then:One minor change vs. the implementation in the
awaitedtypes implementation is that this version detects unions with more than two constituents (i.e.,T | PromiseLike<T> | Promise<T>) as long as all of the constituents are essentially promises forT.