Uh oh!
There was an error while loading. Please reload this page.
Improve type inference for types like 'T | Promise<T>' - #32460
Conversation
Anders Hejlsberg (ahejlsberg)
commented
Jul 17, 2019
TypeScript Bot (@typescript-bot) run dt |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at c6b77fa. You can monitor the build here. It should now contribute to this PR's status checks. |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at c6b77fa. You can monitor the build here. It should now contribute to this PR's status checks. |
Anders Hejlsberg (ahejlsberg)
commented
Jul 18, 2019
Latest commit fixes an issue where strangely we infer nothing for declarefunctionflatten<T>(array: ReadonlyArray<ReadonlyArray<T>>): T[];declareletnaa: number[][];letna=flatten(naa);Before the commit, |
Anders Hejlsberg (ahejlsberg)
commented
Jul 18, 2019
TypeScript Bot (@typescript-bot) run dt |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at 8f02055. You can monitor the build here. It should now contribute to this PR's status checks. |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 8f02055. You can monitor the build here. It should now contribute to this PR's status checks. |
Tim Suchanek (timsuchanek)
commented
Jul 18, 2019
Anders Hejlsberg (@ahejlsberg) you're probably very busy, but in case you find the time, it would be great if you could have a look at #32100 🙏 |
Anders Hejlsberg (ahejlsberg)
commented
Jul 20, 2019
TypeScript Bot (@typescript-bot) run dt |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at 623a172. You can monitor the build here. It should now contribute to this PR's status checks. |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 623a172. You can monitor the build here. It should now contribute to this PR's status checks. |
Anders Hejlsberg (ahejlsberg)
commented
Jul 20, 2019
RWC tests look good. Only one change in |
Anders Hejlsberg (ahejlsberg)
commented
Jul 20, 2019
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 2541a5d. You can monitor the build here. It should now contribute to this PR's status checks. |
Anders Hejlsberg (ahejlsberg)
commented
Jul 21, 2019
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 9b2d9cd. You can monitor the build here. It should now contribute to this PR's status checks. |
Anders Hejlsberg (ahejlsberg)
commented
Jul 22, 2019
TypeScript Bot (@typescript-bot) user test this |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized community code test suite on this PR at 203fd9f. You can monitor the build here. It should now contribute to this PR's status checks. |
TypeScript Bot (typescript-bot)
commented
Jul 22, 2019
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
Anders Hejlsberg (ahejlsberg)
commented
Jul 22, 2019
Verified that user test suite differences are all preexisting conditions. |
Anders Hejlsberg (ahejlsberg)
commented
Jul 23, 2019
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 5646856. You can monitor the build here. It should now contribute to this PR's status checks. |
Anders Hejlsberg (ahejlsberg)
commented
Jul 23, 2019
Two minor issues in DT tests are covered by DefinitelyTyped/DefinitelyTyped/pull/37057. |
Anders Hejlsberg (ahejlsberg)
commented
Jul 23, 2019
Merging this now. There are a few breaks in the RWC suites that I have reviewed with Ryan Cavanaugh (@RyanCavanaugh). |
Wesley Wigham (weswigham)
commented
Jul 23, 2019
I think this is significantly affecting |
Wesley Wigham (weswigham)
commented
Jul 23, 2019
Scratch that, it might be the node version bump itself that's breaking so much; or at least a fair part of it. |

This PR improves type inference to union types that contain combinations of nested and naked type variables. Previously, we'd always give lower priority to inferences made to naked type variables in union types, but this produced sub-optimal results in some fairly basic scenarios (see #32434).
The improved algorithm for inferring from a single source type or a union of source types to a target union type is:
Some examples:
Previously both of the examples above caused errors.
This PR also fixes an inconsistency we've long had.
We now infer
unknownforTin both cases above (because there is nothing left to infer from when the matching types are eliminated, andThas no constraint or default).Fixes#32434.