-
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
Derive tuple labels for rest elements from array binding patterns #59045
Conversation
@typescript-bot test it |
Hey @DanielRosenwasser, the results of running the DT tests are ready. Everything looks the same! |
@DanielRosenwasser Here are the results of running the user tests with tsc comparing Everything looks good! |
@DanielRosenwasser Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@DanielRosenwasser Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
I already have a very related change to this open here. Both PRs touch the same area of the code and solve very overlapping problems, I think it would make sense to merge both |
Seems fine to me, but does need a sync from main and baseline update. |
a497918
to
ae645c3
Compare
While working on #58243, a community member asked if we could label the tuple we use to properly type arguments to the
next()
methods of iterators and generators. A brief experiment showed that directly labeling the tuple element resulted in the creation of thousands of new types in some tests since iterator/generator instantiations would produce new named tuple elements since named tuple elements are cached far less frequently.An alternative to that approach would be to use an additional source for the label when the label comes from a rest parameter whose name is actually an
ArrayBindingPattern
:Since this is merely treated as an additional labeling source, there is no need to synthesize additional types for named tuple elements.
This also improves label inference in other cases such as elision and object assignment pattern elements:
Related #58243 (comment)
Fixes #56289
Closes #57619