Skip to content
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
14 changes: 14 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15358,6 +15358,20 @@ namespace ts {
return getSymbolOfNode(entityName.parent);
}

if (isInJavaScriptFile(entityName) && entityName.parent.kind === SyntaxKind.PropertyAccessExpression) {
const specialPropertyAssignmentKind = getSpecialPropertyAssignmentKind(entityName.parent.parent);
switch (specialPropertyAssignmentKind) {
case SpecialPropertyAssignmentKind.ExportsProperty:
case SpecialPropertyAssignmentKind.PrototypeProperty:
return getSymbolOfNode(entityName.parent);
case SpecialPropertyAssignmentKind.ThisProperty:
case SpecialPropertyAssignmentKind.ModuleExports:
return getSymbolOfNode(entityName.parent.parent);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume in most cases it won't be a "specialPropertyAssignmentKind" and you will just fall through here? Can you make this clear in the code by explicitly adding a default: with just a comment to this effect, or wrapping the switch in an if(specialPropertyAssignmentKind...)?

default:
// Fall through if it is not a special property assignment
}
}

if (entityName.parent.kind === SyntaxKind.ExportAssignment) {
return resolveEntityName(<Identifier>entityName,
/*all meanings*/ SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias);
Expand Down
12 changes: 12 additions & 0 deletions tests/cases/fourslash/renameCrossJsTs01.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>

// @allowJs: true
// @Filename: a.js
////exports.[|area|] = function (r) { return r * r; }

// @Filename: b.ts
////import { [|area|] } from './a';
////var t = /**/[|area|](10);

goTo.marker();
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
12 changes: 12 additions & 0 deletions tests/cases/fourslash/renameCrossJsTs02.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>

// @allowJs: true
// @Filename: a.js
////exports./**/[|area|] = function (r) { return r * r; }

// @Filename: b.ts
////import { [|area|] } from './a';
////var t = [|area|](10);

goTo.marker();
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
12 changes: 12 additions & 0 deletions tests/cases/fourslash/renameJsExports01.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>

// @allowJs: true
// @Filename: a.js
////exports.[|area|] = function (r) { return r * r; }

// @Filename: b.js
////var mod = require('./a');
////var t = mod./**/[|area|](10);

goTo.marker();
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
12 changes: 12 additions & 0 deletions tests/cases/fourslash/renameJsExports02.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>

// @allowJs: true
// @Filename: a.js
////exports./**/[|area|] = function (r) { return r * r; }

// @Filename: b.js
////var mod = require('./a');
////var t = mod.[|area|](10);

goTo.marker();
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
12 changes: 12 additions & 0 deletions tests/cases/fourslash/renameJsPrototypeProperty01.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>

// @allowJs: true
// @Filename: a.js
////function bar() {
////}
////bar.prototype.[|x|] = 10;
////var t = new bar();
////t./**/[|x|] = 11;

goTo.marker();
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
12 changes: 12 additions & 0 deletions tests/cases/fourslash/renameJsPrototypeProperty02.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>

// @allowJs: true
// @Filename: a.js
////function bar() {
////}
////bar.prototype./**/[|x|] = 10;
////var t = new bar();
////t.[|x|] = 11;

goTo.marker();
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
12 changes: 12 additions & 0 deletions tests/cases/fourslash/renameJsThisProperty01.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>

// @allowJs: true
// @Filename: a.js
////function bar() {
//// this.[|x|] = 10;
////}
////var t = new bar();
////t./**/[|x|] = 11;

goTo.marker();
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
12 changes: 12 additions & 0 deletions tests/cases/fourslash/renameJsThisProperty02.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>

// @allowJs: true
// @Filename: a.js
////function bar() {
//// this./**/[|x|] = 10;
////}
////var t = new bar();
////t.[|x|] = 11;

goTo.marker();
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);