Skip to content

Commit 3f577b8

Browse files
mjbvzmhegazy
authored andcommitted
Fix quick info for require template string (microsoft#20851)
* Fix quick info for require template string Fixes microsoft#20850 * Add path completions tests
1 parent 2ea5f58 commit 3f577b8

4 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/compiler/checker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24470,6 +24470,7 @@ namespace ts {
2447024470
return undefined;
2447124471

2447224472
case SyntaxKind.StringLiteral:
24473+
case SyntaxKind.NoSubstitutionTemplateLiteral:
2447324474
// 1). import x = require("./mo/*gotToDefinitionHere*/d")
2447424475
// 2). External module name in an import declaration
2447524476
// 3). Dynamic import call or require in javascript

src/services/findAllReferences.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ namespace ts.FindAllReferences.Core {
275275
}
276276

277277
function isModuleReferenceLocation(node: ts.Node): boolean {
278-
if (node.kind !== SyntaxKind.StringLiteral) {
278+
if (node.kind !== SyntaxKind.StringLiteral && node.kind !== SyntaxKind.NoSubstitutionTemplateLiteral) {
279279
return false;
280280
}
281281
switch (node.parent.kind) {

tests/cases/fourslash/completionsPaths.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,14 @@
1717
// @Filename: /src/folder/b.ts
1818
////import {} from "x//*2*/";
1919

20+
// @Filename: /src/folder/c.ts
21+
////const foo = require("x//*3*/");
22+
23+
// @Filename: /src/folder/4.ts
24+
////const foo = require(`x//*4*/`);
25+
2026
verify.completionsAt("1", ["y", "x"]);
2127
verify.completionsAt("2", ["bar", "foo"]);
28+
verify.completionsAt("3", ["bar", "foo"]);
29+
verify.completionsAt("4", ["bar", "foo"]);
30+

tests/cases/fourslash/quickInfoForRequire.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
//@Filename: quickInfoForRequire_input.ts
77
////import a = require("./AA/B/*1*/B");
8+
////import b = require(`./AA/B/*2*/B`);
9+
810

911
goTo.marker("1");
1012
verify.quickInfoIs("module a");
13+
14+
goTo.marker("2");
15+
verify.quickInfoIs("module a");

0 commit comments

Comments
 (0)