Skip to content

fix(57022): Rename of string literal property name doesn't rename all occurences #57201

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/services/findAllReferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ interface PrefixAndSuffix {
readonly suffixText?: string;
}
function getPrefixAndSuffixText(entry: Entry, originalNode: Node, checker: TypeChecker, quotePreference: QuotePreference): PrefixAndSuffix {
if (entry.kind !== EntryKind.Span && isIdentifier(originalNode)) {
if (entry.kind !== EntryKind.Span && (isIdentifier(originalNode) || isStringLiteralLike(originalNode))) {
const { node, kind } = entry;
const parent = node.parent;
const name = originalNode.text;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// === findRenameLocations ===
// === /tests/cases/fourslash/renameStringPropertyNames2.ts ===
// type Props = {
// <|[|fooRENAME|]: boolean;|>
// }
//
// <|let { [|fooRENAME|]: foo/*END SUFFIX*/ }: Props = null as any;|>
// foo;
//
// let asd: Props = { <|"[|fooRENAME|]"/*RENAME*/: true|> }; // rename foo here
12 changes: 12 additions & 0 deletions tests/cases/fourslash/renameStringPropertyNames2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference path="fourslash.ts" />

////type Props = {
//// foo: boolean;
////}
////
////let { foo }: Props = null as any;
////foo;
////
////let asd: Props = { "foo"/**/: true }; // rename foo here

verify.baselineRename("", {});