Skip to content

Commit

Permalink
fix(57022): Rename of string literal property name doesn't rename all…
Browse files Browse the repository at this point in the history
… occurences (#57201)
  • Loading branch information
Zzzen committed May 24, 2024
1 parent 7ad8f39 commit af3a61f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
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("", {});

0 comments on commit af3a61f

Please sign in to comment.