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 doesn't work on declaration whose name is a string literal #57026

Open
sandersn opened this issue Jan 11, 2024 · 0 comments · May be fixed by #61353
Open

Rename doesn't work on declaration whose name is a string literal #57026

sandersn opened this issue Jan 11, 2024 · 0 comments · May be fixed by #61353
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

Comments

@sandersn
Copy link
Member

Follow up to #56052, which was fixed by #56061. That fix means that rename from string literal values that are contextually typed by the type of the string-literal-named property do work. But renames on the actual property declaration still don't.

interface I {
    "Prop 1 Foo": string
    // ^-- rename here doesn't work
}
declare const fn: <K extends keyof I>(p: K) => void
fn("Prop 1 Foo")

Playground link

As before, if you use constant with a literal type, renaming the literal type does work:

declare const indirect: "Prop 1 Foo"
interface I {
  [indirect]: string
}
// ... same as before ...
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
Development

Successfully merging a pull request may close this issue.

1 participant