Skip to content

Commit af3a61f

Browse files
authored
fix(57022): Rename of string literal property name doesn't rename all occurences (#57201)
1 parent 7ad8f39 commit af3a61f

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/services/findAllReferences.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ interface PrefixAndSuffix {
757757
readonly suffixText?: string;
758758
}
759759
function getPrefixAndSuffixText(entry: Entry, originalNode: Node, checker: TypeChecker, quotePreference: QuotePreference): PrefixAndSuffix {
760-
if (entry.kind !== EntryKind.Span && isIdentifier(originalNode)) {
760+
if (entry.kind !== EntryKind.Span && (isIdentifier(originalNode) || isStringLiteralLike(originalNode))) {
761761
const { node, kind } = entry;
762762
const parent = node.parent;
763763
const name = originalNode.text;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// === findRenameLocations ===
2+
// === /tests/cases/fourslash/renameStringPropertyNames2.ts ===
3+
// type Props = {
4+
// <|[|fooRENAME|]: boolean;|>
5+
// }
6+
//
7+
// <|let { [|fooRENAME|]: foo/*END SUFFIX*/ }: Props = null as any;|>
8+
// foo;
9+
//
10+
// let asd: Props = { <|"[|fooRENAME|]"/*RENAME*/: true|> }; // rename foo here
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////type Props = {
4+
//// foo: boolean;
5+
////}
6+
////
7+
////let { foo }: Props = null as any;
8+
////foo;
9+
////
10+
////let asd: Props = { "foo"/**/: true }; // rename foo here
11+
12+
verify.baselineRename("", {});

0 commit comments

Comments
 (0)