Skip to content
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 Symbol F2 with "pure keyof" is not possible - but it is possible if "wrapped as calculated property" #56052

Closed
qwertysk opened this issue Oct 10, 2023 · 4 comments · Fixed by #56061
Labels
Domain: Refactorings e.g. extract to constant or function, rename symbol Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Suggestion An idea for TypeScript
Milestone

Comments

@qwertysk
Copy link

qwertysk commented Oct 10, 2023

I think this could be related to typescript only, even I reported it also here typescript-language-server/typescript-language-server#767

🔎 Search Terms

Rename symbol, keyof

🕗 Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

https://tsplay.dev/N7QgPW

💻 Code

////////////////////////// CASE 1 - keyof to computed property /////////////////////////

declare const Att_1: "Att 1"

interface Case_1 {
  [Att_1]: string
}

declare const fnc_1: <K extends keyof Case_1>(p: K) => void

fnc_1("Att 1")
//     ^_ Rename Symbol F2 => SUCCESS



////////////////////////// CASE 2 - pure keyof //////////////////////////

interface Case_2 {
  "Att 2": string // here is the difference, pls compare to Case_1
}

declare const fnc_2: <K extends keyof Case_2>(p: K) => void

fnc_2("Att 2")
//     ^_ Rename Symbol F2 => FAIL

🙁 Actual behavior

image

It is wrong because Att 2 in interface Case_2 is not renamed

🙂 Expected behavior

I expect Att 2 in interface Case_2 to be successfully renamed to Attribute 2

Additional information about the issue

Even it is not "a bug but the feature", is there best practice - if reliable renaming is really frequent and important in my project ?

PLS HELP ME ❤️❤️❤️ ... because manually create tons of constants for all project interfaces and all attributes - this is not maintanable way - any other ideas/patterns please ?

@qwertysk qwertysk changed the title Renaming Symbol F2 with "pure keyof" is not possible - but it is possible if "wrapped as calculated property" Rename Symbol F2 with "pure keyof" is not possible - but it is possible if "wrapped as calculated property" Oct 10, 2023
@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Help Wanted You can do this Experience Enhancement Noncontroversial enhancements Domain: Refactorings e.g. extract to constant or function, rename symbol labels Oct 10, 2023
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Oct 10, 2023
@qwertysk
Copy link
Author

qwertysk commented Dec 12, 2023

@sandersn, @RyanCavanaugh, @a-tarasyuk this issue is not fixed - try it yourself pls, see playground link above.

@a-tarasyuk
Copy link
Contributor

@qwertysk Playground - Both examples can be renamed. Could you provide additional cases that should be covered?

foo.mov

@qwertysk
Copy link
Author

qwertysk commented Dec 13, 2023

@sandersn, @RyanCavanaugh, @a-tarasyuk here are details - pls see that rename doesn't work both ways

image

Playground

@sandersn
Copy link
Member

I opened #57026 to track the follow-up fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Refactorings e.g. extract to constant or function, rename symbol Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
4 participants