-
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
Attempt to reduce types which are about to produce a complexity error #53739
base: main
Are you sure you want to change the base?
Attempt to reduce types which are about to produce a complexity error #53739
Conversation
@typescript-bot test this |
Heya @weswigham, I've started to run the extended test suite on this PR at 2d21364. You can monitor the build here. |
Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at 2d21364. You can monitor the build here. |
Heya @weswigham, I've started to run the diff-based top-repos suite on this PR at 2d21364. You can monitor the build here. |
Heya @weswigham, I've started to run the perf test suite on this PR at 2d21364. You can monitor the build here. |
Modified the implementation slightly to reduce each element being considered a bit more aggressively and then the test case from #53234. |
@typescript-bot test this |
Heya @weswigham, I've started to run the tarball bundle task on this PR at 757c56a. You can monitor the build here. |
Heya @weswigham, I've started to run the perf test suite on this PR at 757c56a. You can monitor the build here. Update: The results are in! |
Heya @weswigham, I've started to run the diff-based top-repos suite on this PR at 757c56a. You can monitor the build here. Update: The results are in! |
Heya @weswigham, I've started to run the extended test suite on this PR at 757c56a. You can monitor the build here. |
Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at 757c56a. You can monitor the build here. Update: The results are in! |
Hey @weswigham, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
@weswigham Here they are:
CompilerComparison Report - main..53739
System
Hosts
Scenarios
TSServerComparison Report - main..53739
System
Hosts
Scenarios
StartupComparison Report - main..53739
System
Hosts
Scenarios
Developer Information: |
@typescript-bot perf test this faster |
Heya @gabritto, I've started to run the abridged perf test suite on this PR at 757c56a. You can monitor the build here. Update: The results are in! |
Hey @weswigham, the results of running the DT tests are ready. |
@weswigham Here are the results of running the top-repos suite comparing Everything looks good! |
if (i === typeSet.length - 1 || isTypeAny(runningResult) || runningResult.flags & TypeFlags.Never) { | ||
return runningResult; | ||
} | ||
if (!(runningResult.flags & TypeFlags.Union) || (runningResult as UnionType).types.length > typeSet.length) { |
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.
Why do we bail if the second condition here is true ((runningResult as UnionType).types.length > typeSet.length
)? Is it because then the heuristic is not being helpful in reducing the number of types to intersect?
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.
Yeah. If going element-by-element is growing the type, this probably isn't helping, so we give up on it.
@gabritto Here they are:Comparison Report - main..53739
System
Hosts
Scenarios
Developer Information: |
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.
Looks good to me. It would be nice though to confirm that the perf regression in xstate
happens because there's an expression too complex compilation error.
@weswigham Is this ready to go? I don't know whether you want to double check xstate results first or not. |
Basically #42772 but synced with
main
, but also improves how often we defer union/intersection member types; namely with this we now always defer construction of a union or intersection's symbol's type if one of its' constituent symbols is itself deferred. I had to add this in to the original change, as in the intervening time between the original PR and now, we got noticeably worse at deferring union members, and actually started manufacturing members likeref
even if they weren't explicitly referenced (in this case, to check if the member can be used for contextual type discimination, which jsx now tries).The original PR description (which is also still true) for reference:
Fixes #53234