diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ac5012a3bf9..6f9e9d45977 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -20930,7 +20930,9 @@ namespace ts { return getSymbolOfNode(entityName.parent); } - if (isInJavaScriptFile(entityName) && entityName.parent.kind === SyntaxKind.PropertyAccessExpression) { + if (isInJavaScriptFile(entityName) && + entityName.parent.kind === SyntaxKind.PropertyAccessExpression && + entityName.parent === (entityName.parent.parent as BinaryExpression).left) { // Check if this is a special property assignment const specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); if (specialPropertyAssignmentSymbol) { diff --git a/tests/cases/fourslash/renameJsSpecialAssignmentRhs1.ts b/tests/cases/fourslash/renameJsSpecialAssignmentRhs1.ts new file mode 100644 index 00000000000..b4b9fb80528 --- /dev/null +++ b/tests/cases/fourslash/renameJsSpecialAssignmentRhs1.ts @@ -0,0 +1,13 @@ +/// +// @allowJs: true +// @Filename: a.js +////const foo = { +//// set: function (x) { +//// this._x = x; +//// }, +//// copy: function ([|x|]) { +//// this._x = /**/[|x|].prop; +//// } +////}; +goTo.marker(); +verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); diff --git a/tests/cases/fourslash/renameJsSpecialAssignmentRhs2.ts b/tests/cases/fourslash/renameJsSpecialAssignmentRhs2.ts new file mode 100644 index 00000000000..5b4b6e851cf --- /dev/null +++ b/tests/cases/fourslash/renameJsSpecialAssignmentRhs2.ts @@ -0,0 +1,13 @@ +/// +// @allowJs: true +// @Filename: a.js +////const foo = { +//// set: function (x) { +//// this._x = x; +//// }, +//// copy: function (/**/[|x|]) { +//// this._x = [|x|].prop; +//// } +////}; +goTo.marker(); +verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);