-
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
Divide-and-conquer strategy for intersections of unions #57871
Conversation
@typescript-bot test top200 |
@ahejlsberg Here are the results of running the user test suite comparing Everything looks good! |
@ahejlsberg Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@ahejlsberg Here are the results of running the top-repos suite comparing Everything looks good! |
@typescript-bot run dt |
Hey @ahejlsberg, the results of running the DT tests are ready. Branch only errors:Package: amap-js-api-driving
Package: amap-js-api-riding
Package: amap-js-api-transfer
|
@ahejlsberg Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@typescript-bot run dt |
Hey @ahejlsberg, the results of running the DT tests are ready. |
Tests and performance are unaffected. This is ready for a review. |
@typescript-bot cherry-pick this to release-5.4 |
Hey, @jakebailey! I was unable to cherry-pick this PR. Check the logs at: https://github.com/microsoft/TypeScript/actions/runs/8380435679 |
@typescript-bot cherry-pick this to release-5.4 |
Hey, @jakebailey! I've created #57893 for you. This involved updating baselines; please check the diff. |
This is huge, thank you so much! I've been working around this limitation in my library for almost a year now. These changes allow me to do so much more now! 🎉❤️ |
@ahejlsberg I would like to see a patch release on top of 5.4 with these changes. Is there anything I can do to help get this out there? |
…e-5.4 (#57893) Co-authored-by: Anders Hejlsberg <[email protected]>
This is backported (see above), and will be in the next patch. |
With this PR we implement a "divide and conquer" strategy for handling large intersections of union types. Specifically, when creating an intersection with four or more constituents, some of which are unions, we divide the constituents into two groups such that
A & B & C & D
is processed as(A & B) & (C & D)
. Since intersections of unions often produce far smaller unions of intersections than the full cartesian product (due to some intersections becomingnever
), this can dramatically reduce the overall work at the cost of generating slightly more types (because of the temporary intersections). For example, the reduced repro from #57863 that barely passes before this PR takes 0.28s to type check. That drops to 0.08s with this PR.Fixes #57863.