-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Implement on-type-rename for TypeScript #110573
Conversation
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.
Neat! Change looks good to me overall
Should we ask TS for a proper API? Besides having to make two calls, are there any major issues with the current approach that TS could solve?
extensions/typescript-language-features/src/languageFeatures/renameOnType.ts
Outdated
Show resolved
Hide resolved
One other question: does this work for renaming JSX elements? This was a highly upvoted issue: microsoft/TypeScript#51832 |
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.
lllll`
fyi - I have also added
For JSX it seem that they are reported as |
Is it proper to call is "renaming"? Say I have two components: Looking at the implementation I think this pr is also doing the later let bar = 1;
let baz = 2;
console.log(bar); // change this `bar` to `baz`, I don't want to rename the variable to `baz`, I just want to use `baz` instead |
Yes - as of today it is like f2-rename (which the name of the feature also implies). What I hear from you is to only rename usages and not the declaration in some cases. Unsure how such cases would be defined? Depending on where the cursor location is? |
In Visual Studio and C#, after changing the name of something, there will be a code action to let you apply the edit as renaming, it will never do this by its own. (see #90361) Maybe it's feasible to automatically rename something when cursor is on its declaration, but it's still possible that the user really want to do is replacing the implementation, so they rename the current one (as a backup), and add a new one with same name. |
Sure, sure. That's why this is a feature that's off by default and also when its active you get clear feedback UX and can then cancel via ESC |
This PR fixes nothing but explores on-type-rename for TS. There is no "proper" tsserver support for this but what I have seems to work surprisingly well.