Bring back renamings in emitted d.ts files #55678
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #55654 (with the unfortunate solution)
This isn't ideal. I think the direction we want to go is to not emit renamings if we don't have to, but the current implementation uses
isReferenced
which unfortunately considers references other than those that affect the signatures of the functions. So if you ever actually use the parameter you've renamed, then it will be kept, even if that isn't required. In the real world, that'd of course be nearly all instances, because there's usually no reason to destructure a parameter and then not use it. Of course our tests have a lot of this because we typically don't care about what's inside a function, or we don't have a body at all!This with #50779 effectively reverts all of #41044 except the new error. You'll notice that this PR's baseline changes don't contain any new errors, which is good. This is because the error only happens when the signature doesn't have an annotation, e.g.:
The former can't happen in emitted
d.ts
files; we're always going to fully annotate the output.Maybe there's a solution that would instead attempt to figure out if the name is ever actually used elsewhere, but I'm not sure how to do that. I feel like we probably have that logic somewhere for other reasons? In which case, I'm happy to redo the PR.