Fix quick info for require template string (#20851)

* Fix quick info for require template string

Fixes #20850

* Add path completions tests
This commit is contained in:
Matt Bierner 2018-01-04 15:17:40 -08:00 committed by Mohamed Hegazy
parent 2ea5f58d60
commit 3f577b8617
4 changed files with 16 additions and 1 deletions

View file

@ -24470,6 +24470,7 @@ namespace ts {
return undefined;
case SyntaxKind.StringLiteral:
case SyntaxKind.NoSubstitutionTemplateLiteral:
// 1). import x = require("./mo/*gotToDefinitionHere*/d")
// 2). External module name in an import declaration
// 3). Dynamic import call or require in javascript

View file

@ -275,7 +275,7 @@ namespace ts.FindAllReferences.Core {
}
function isModuleReferenceLocation(node: ts.Node): boolean {
if (node.kind !== SyntaxKind.StringLiteral) {
if (node.kind !== SyntaxKind.StringLiteral && node.kind !== SyntaxKind.NoSubstitutionTemplateLiteral) {
return false;
}
switch (node.parent.kind) {

View file

@ -17,5 +17,14 @@
// @Filename: /src/folder/b.ts
////import {} from "x//*2*/";
// @Filename: /src/folder/c.ts
////const foo = require("x//*3*/");
// @Filename: /src/folder/4.ts
////const foo = require(`x//*4*/`);
verify.completionsAt("1", ["y", "x"]);
verify.completionsAt("2", ["bar", "foo"]);
verify.completionsAt("3", ["bar", "foo"]);
verify.completionsAt("4", ["bar", "foo"]);

View file

@ -5,6 +5,11 @@
//@Filename: quickInfoForRequire_input.ts
////import a = require("./AA/B/*1*/B");
////import b = require(`./AA/B/*2*/B`);
goTo.marker("1");
verify.quickInfoIs("module a");
goTo.marker("2");
verify.quickInfoIs("module a");