Uh oh!
There was an error while loading. Please reload this page.
Rename type parameters when they are shadowed. - #61342
Conversation
bb3168b to
17f68c3CompareJake Bailey (jakebailey)
commented
Mar 4, 2025
TypeScript Bot (@typescript-bot) pack this |
Hey Jake Bailey (@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 |
Wesley Wigham (weswigham)
left a comment
There was a problem hiding this comment.
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.
Jake Bailey (jakebailey)
commented
Mar 4, 2025
TypeScript Bot (@typescript-bot) cherry-pick this to release-5.8 |
TypeScript Bot (typescript-bot)
commented
Mar 4, 2025
Hey, Jake Bailey (@jakebailey)! I've created #61345 for you. |
…e-5.8 (#61345) Co-authored-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
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
Tis 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.