-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Feature request: Track references of string literals on keys and vice-versa for better intellisense #45549
Comments
I sort of thought this did work, at least in simple cases, but looks like we never consider string literals for rename/references with interface A {
a: string;
}
declare function f(a: A, k: keyof A): void;
declare let a: A;
f(a, "a"); I think Iβd expect these to work, but wouldnβt be surprised if itβs complicated/expensive. |
Labeled for Effort: Moderately Difficult? |
FWIW, I think getting my example to work would be a win, and would probably fix the |
I was surprised you marked it as "bug" but then realized it indeed is a bug -- as the renaming refactor produces a compile error! xD |
* Enables string literals in call expression to refer to property names. * Enables property names in call expression to refer to string literals. * Changes string literal rename/reference behavior when string literals are in a call expression. Previously, all string references with matching text would reference one another globally and allow renaming even if such an operation would result in a compiler error. Fixes microsoft#45549
* Enables string literals in call expression to refer to property names. * Enables property names in call expression to refer to string literals. * Changes string literal rename/reference behavior when string literals are in a call expression. Previously, all string references with matching text would reference one another globally and allow renaming even if such an operation would result in a compiler error. Fixes microsoft#45549
Suggestion
π Search Terms
rename string literals, refactor
β Viability Checklist
β Suggestion
Playground for code below
π Motivating Example
A bunch of popular libraries that will benefit from this for example...
1. xstate
This feature will enable ctrl+click on "doStuff" in index.tsx navigating to "doStuff" in machine.ts and renaming both "doStuff" by renaming either of them (given the types are correct ofc)
2. stitches
Taken from here
Here the string literal
"violet"
in<Button color="violet">Button</Button>
references theviolet
key in the object passed tostyled
function3. framer-motion
Taken from here
Here the string literals
"open"
and"close"
inmotion.nav
'sanimate
reference the keys ofvariants
passed to it.These three come to my mind right now, but I think this is a very common pattern so the improvement in the intellisense will have a significant impact.
The text was updated successfully, but these errors were encountered: