-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Don't eagerly simplify reducible generic union index types #46812
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
Don't eagerly simplify reducible generic union index types #46812
Conversation
@typescript-bot perf test this |
Heya @andrewbranch, I've started to run the perf test suite on this PR at 43bfe00. You can monitor the build here. Update: The results are in! |
Heya @andrewbranch, I've started to run the inline community code test suite on this PR at 43bfe00. You can monitor the build here. Update: The results are in! |
Heya @andrewbranch, I've started to run the parallelized Definitely Typed test suite on this PR at 43bfe00. You can monitor the build here. |
@andrewbranch |
@andrewbranch Here they are:Comparison Report - main..46812
System
Hosts
Scenarios
Developer Information: |
All the extended CI results and perf look fine. Reviews please~ |
@weswigham Is this ready? Does it need another review? I just noticed it when going through the Needs Merge column of the PR backlog. |
Fixes #45530
The issue wasn't that the mapped types were losing information, per sey, in fact, they were responsible for rehydrating missing information in some instances - instead, the issue was that we were too eagerly reducing the
keyof
result of unions over types which might have been reduced upon instantiation, like({v: T} & {v: "a", a: string}) | ({v: T} & {v: "b", b: string})
. Before this change,keyof
that was just"v"
, while now it will remain the generickeyof (({v: T} & {v: "a", a: string}) | ({v: T} & {v: "b", b: string}))
, since instantiation can make it simplify to eitherkeyof ({v: "a"} & {v: "a", a: string})
orkeyof ({v: "b"} & {v: "b", b: string})
, which have keys"v" | "a"
or"v" | "b"
, respectively. (Which in turn trickles down to assignability behavior of mapped types over those kinds ofkeyof
types)