Skip to content

Commit deb9488

Browse files
Kingwlmhegazy
authored andcommitted
fix completion module path (microsoft#19351)(microsoft#19367) (microsoft#19366)
* completion module path with re-export(microsoft#19351) * completion module path with dynamic import(microsoft#19367)
1 parent ce25dc9 commit deb9488

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

src/services/completions.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,15 @@ namespace ts.Completions {
241241
// a['/*completion position*/']
242242
return getStringLiteralCompletionEntriesFromElementAccess(node.parent, typeChecker, compilerOptions.target, log);
243243
}
244-
else if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isRequireCall(node.parent, /*checkArgumentIsStringLiteral*/ false)) {
244+
else if (node.parent.kind === SyntaxKind.ImportDeclaration || node.parent.kind === SyntaxKind.ExportDeclaration
245+
|| isRequireCall(node.parent, /*checkArgumentIsStringLiteral*/ false) || isImportCall(node.parent)
246+
|| isExpressionOfExternalModuleImportEqualsDeclaration(node)) {
245247
// Get all known external module names or complete a path to a module
246248
// i.e. import * as ns from "/*completion position*/";
249+
// var y = import("/*completion position*/");
247250
// import x = require("/*completion position*/");
248251
// var y = require("/*completion position*/");
252+
// export * from "/*completion position*/";
249253
return PathCompletions.getStringLiteralCompletionEntriesFromModuleNames(<StringLiteral>node, compilerOptions, host, typeChecker);
250254
}
251255
else if (isEqualityExpression(node.parent)) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// Should define spans for replacement that appear after the last directory seperator in export statements
4+
5+
// @typeRoots: my_typings
6+
7+
// @Filename: test.ts
8+
//// export * from "./some/*0*/
9+
//// export * from "./sub/some/*1*/";
10+
//// export * from "some-/*2*/";
11+
//// export * from "..//*3*/";
12+
//// export {} from ".//*4*/";
13+
14+
15+
// @Filename: someFile1.ts
16+
//// /*someFile1*/
17+
18+
// @Filename: sub/someFile2.ts
19+
//// /*someFile2*/
20+
21+
// @Filename: my_typings/some-module/index.d.ts
22+
//// export var x = 9;
23+
24+
goTo.marker("0");
25+
verify.completionListContains("someFile1");
26+
27+
goTo.marker("1");
28+
verify.completionListContains("someFile2");
29+
30+
goTo.marker("2");
31+
verify.completionListContains("some-module");
32+
33+
goTo.marker("3");
34+
verify.completionListContains("fourslash");
35+
36+
goTo.marker("4");
37+
verify.completionListContains("someFile1");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// Should define spans for replacement that appear after the last directory seperator in dynamic import statements
4+
5+
// @typeRoots: my_typings
6+
7+
// @Filename: test.ts
8+
//// const a = import("./some/*0*/
9+
//// const a = import("./sub/some/*1*/");
10+
//// const a = import("some-/*2*/");
11+
//// const a = import("..//*3*/");
12+
13+
14+
// @Filename: someFile1.ts
15+
//// /*someFile1*/
16+
17+
// @Filename: sub/someFile2.ts
18+
//// /*someFile2*/
19+
20+
// @Filename: my_typings/some-module/index.d.ts
21+
//// export var x = 9;
22+
23+
goTo.marker("0");
24+
verify.completionListContains("someFile1");
25+
26+
goTo.marker("1");
27+
verify.completionListContains("someFile2");
28+
29+
goTo.marker("2");
30+
verify.completionListContains("some-module");
31+
32+
goTo.marker("3");
33+
verify.completionListContains("fourslash");

0 commit comments

Comments
 (0)