-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Defer distributing index over generic object types #50540
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
Defer distributing index over generic object types #50540
Conversation
@typescript-bot test this |
Heya @DanielRosenwasser, I've started to run the diff-based user code test suite on this PR at 00e3926. You can monitor the build here. Update: The results are in! |
Heya @DanielRosenwasser, I've started to run the extended test suite on this PR at 00e3926. You can monitor the build here. |
Heya @DanielRosenwasser, I've started to run the perf test suite on this PR at 00e3926. You can monitor the build here. Update: The results are in! |
Heya @DanielRosenwasser, I've started to run the parallelized Definitely Typed test suite on this PR at 00e3926. You can monitor the build here. |
@DanielRosenwasser Here are the results of running the user test suite comparing Everything looks good! |
Heya @DanielRosenwasser, I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here. |
@DanielRosenwasser Here they are:
CompilerComparison Report - main..50540
System
Hosts
Scenarios
TSServerComparison Report - main..50540
System
Hosts
Scenarios
Developer Information: |
@typescript-bot test top100 |
Heya @DanielRosenwasser, I've started to run the diff-based user code test suite on this PR at 00e3926. You can monitor the build here. |
@DanielRosenwasser @sandersn Looks like the top100 test is bombing out in one of the processes. Same issue over in #50535. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change makes sense, but I'd prefer reducing the scope a bit as suggested here.
src/compiler/checker.ts
Outdated
if (shouldDeferIndexType(objectType)) { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this.
@@ -15903,6 +15903,9 @@ namespace ts { | |||
} | |||
|
|||
function distributeIndexOverObjectType(objectType: Type, indexType: Type, writing: boolean) { | |||
if (shouldDeferIndexType(objectType)) { | |||
return; | |||
} | |||
// (T | U)[K] -> T[K] | U[K] (reading) | |||
// (T | U)[K] -> T[K] & U[K] (writing) | |||
// (T & U)[K] -> T[K] & U[K] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the following line to:
if (objectType.flags & TypeFlags.Union || objectType.Flags & TypeFlags.Intersection && !shouldDeferIndexType(objectType)) ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned that shouldDeferIndexType
will also do (possibly expensive) work for union types, so I'd prefer only deferring for intersection types.
@ahejlsberg I've applied the suggested change and rerun the test suite locally - everything looks OK on this front, somebody from the TS team has to start new perf tests though. |
@typescript-bot perf test this my liege |
Heya @jakebailey, I've started to run the perf test suite on this PR at 2ba9ff1. You can monitor the build here. Update: The results are in! |
@jakebailey Here they are:
CompilerComparison Report - main..50540
System
Hosts
Scenarios
TSServerComparison Report - main..50540
System
Hosts
Scenarios
Developer Information: |
@typescript-bot test this |
Heya @ahejlsberg, I've started to run the diff-based user code test suite on this PR at 2ba9ff1. You can monitor the build here. |
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 2ba9ff1. You can monitor the build here. |
Heya @ahejlsberg, I've started to run the diff-based user code test suite on this PR at 2ba9ff1. You can monitor the build here. Update: The results are in! |
Heya @ahejlsberg, I've started to run the extended test suite on this PR at 2ba9ff1. You can monitor the build here. |
@ahejlsberg Here are the results of running the user test suite comparing Everything looks good! |
Heya @ahejlsberg, I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here. |
ae87342
to
873dfea
Compare
@ahejlsberg should this perhaps be cherry-picked into the 4.8 release? |
@Andarist Yup, it's already on the list. |
@typescript-bot cherry-pick this to release-4.8 |
Heya @andrewbranch, I've started to run the task to cherry-pick this into |
Hey @andrewbranch, I've opened #50588 for you. |
Fixes #50539
cc @ahejlsberg , the
shouldDeferIndexType
check has been introduced based on the changes in this PR: https://github.com/microsoft/TypeScript/pull/49696/files