-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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 and fine all references of Typescript's string literal values #7611
Comments
so should we rename all literal types for example: type Options = "option 1" | "option 2"
let myOption: Options = "option 1" // rename here,
function foo(a: "option 1") { } // should this be renamed as well? |
Fix #7611: Add support for String Literal Types in find all refs and occurances
This does not work as accepted. I don't know if this problem is with Typescript or with VSCode. Just open a new test.ts file with this content in vscode:
press F2 to rename the "aaa" of the A type. the "aaa" of the B type is also renamed. And also the find all references does not work Tried it on vscode 1.7.1 on windows. |
there is really no difference between |
I will have to disagree. Lets take a more concrete example: As typescript doesn't yet have a nameof operator, a common practice, when you need to pass a member name to a function, is to list members using a string literal types. E.g.:
No lets say we decide to rename the members to more meaningful names, like userId and orderId, or userName and orderName. The interfaces will be renamed as accepted, but the string literal types will not. Another example could be tat each have a status member with there own string literal types. and you need to change just a status name og just one of them Also the problem described in #7458 is a different problem. there the rename is of a specific member, and what was wanted is to rename a specific instance of "html" code. Here the problem with article is that it renames something that is entirely unconnected to the renamed object. |
From @zivni on March 20, 2016 8:40
Type script string literals allow to have a code such as
It would be nice to be able to rename and find all references of a specific value. e.g. find/rename all occurrences of "option 1". Currently we can only find the references of the type itself.
Copied from original issue: microsoft/vscode#4469
The text was updated successfully, but these errors were encountered: