-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Rename type parameters when they are shadowed. #61342
Rename type parameters when they are shadowed. #61342
Conversation
bb3168b
to
17f68c3
Compare
@typescript-bot pack this |
Hey @jakebailey, 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 |
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.
Our contexts for shadowing/not in the full checker are approximate as well - we over-rename in many areas already. It's basically expected. What's not is rewriting any input nodes (ie, if we know we're keeping a node the user wrote, then we know that name is locked in and we have to issue an accessibility error when we try to reference it and can't reach it instead). Now, this does technically rewrite an input node, but only in areas the full checker path would have anyway, historically, so it's probably fine. It's not like it's a "semantic" rewrite, either - it's purely symbolic.
@typescript-bot cherry-pick this to release-5.8 |
Hey, @jakebailey! I've created #61345 for you. |
Fixes #61334
Temporary fix. This solution will rename the type parameters. While this solution is valid it is a solution that is incompatible with what a different implementation of declaration emit could produce. This solution always renames the type parameters if they are shadowed even if this is not necessary. A correct solution would only rename them if there was an inference fallback that required access to one of the shadowed parameters.
The first example does not require renaming as the outer
T
is not used in the field type. This example could be emitted by an external tool as well. The second example does require renaming , but it can't be emitted by an external tool anyway so it's not a problem if we rename the type parameters.I am working on a fix that does this, but it does seem important to have a fix that emits a valid declaration file.