Skip to content

Commit 18969b0

Browse files
committed
Handle the require call in javascript file for getSymbolAtLocation
This helps in getting the alias symbol so that it can go to the definition of external module Fixes #9251
1 parent f4dc114 commit 18969b0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18436,6 +18436,9 @@ namespace ts {
1843618436
(<ImportDeclaration>node.parent).moduleSpecifier === node)) {
1843718437
return resolveExternalModuleName(node, <LiteralExpression>node);
1843818438
}
18439+
if (isInJavaScriptFile(node) && isRequireCall(node.parent, /*checkArgumentIsStringLiteral*/ false)) {
18440+
return resolveExternalModuleName(node, <LiteralExpression>node);
18441+
}
1843918442
// Fall through
1844018443

1844118444
case SyntaxKind.NumericLiteral:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
// @allowJs: true
4+
// @Filename: foo.js
5+
/////*2*/module.exports = {};
6+
7+
// @Filename: bar.js
8+
////var x = require(/*1*/"./foo");
9+
10+
debugger;
11+
verify.goToDefinition("1", "2");

0 commit comments

Comments
 (0)