fix completion module path (#19351)(#19367) (#19366)

* completion module path with re-export(#19351)

* completion module path with dynamic import(#19367)
This commit is contained in:
wenlu.wang 2017-10-31 16:10:38 -05:00 committed by Mohamed Hegazy
parent ce25dc9807
commit deb94886fd
3 changed files with 75 additions and 1 deletions

View file

@ -241,11 +241,15 @@ namespace ts.Completions {
// a['/*completion position*/']
return getStringLiteralCompletionEntriesFromElementAccess(node.parent, typeChecker, compilerOptions.target, log);
}
else if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isRequireCall(node.parent, /*checkArgumentIsStringLiteral*/ false)) {
else if (node.parent.kind === SyntaxKind.ImportDeclaration || node.parent.kind === SyntaxKind.ExportDeclaration
|| isRequireCall(node.parent, /*checkArgumentIsStringLiteral*/ false) || isImportCall(node.parent)
|| isExpressionOfExternalModuleImportEqualsDeclaration(node)) {
// Get all known external module names or complete a path to a module
// i.e. import * as ns from "/*completion position*/";
// var y = import("/*completion position*/");
// import x = require("/*completion position*/");
// var y = require("/*completion position*/");
// export * from "/*completion position*/";
return PathCompletions.getStringLiteralCompletionEntriesFromModuleNames(<StringLiteral>node, compilerOptions, host, typeChecker);
}
else if (isEqualityExpression(node.parent)) {

View file

@ -0,0 +1,37 @@
/// <reference path='fourslash.ts' />
// Should define spans for replacement that appear after the last directory seperator in export statements
// @typeRoots: my_typings
// @Filename: test.ts
//// export * from "./some/*0*/
//// export * from "./sub/some/*1*/";
//// export * from "some-/*2*/";
//// export * from "..//*3*/";
//// export {} from ".//*4*/";
// @Filename: someFile1.ts
//// /*someFile1*/
// @Filename: sub/someFile2.ts
//// /*someFile2*/
// @Filename: my_typings/some-module/index.d.ts
//// export var x = 9;
goTo.marker("0");
verify.completionListContains("someFile1");
goTo.marker("1");
verify.completionListContains("someFile2");
goTo.marker("2");
verify.completionListContains("some-module");
goTo.marker("3");
verify.completionListContains("fourslash");
goTo.marker("4");
verify.completionListContains("someFile1");

View file

@ -0,0 +1,33 @@
/// <reference path='fourslash.ts' />
// Should define spans for replacement that appear after the last directory seperator in dynamic import statements
// @typeRoots: my_typings
// @Filename: test.ts
//// const a = import("./some/*0*/
//// const a = import("./sub/some/*1*/");
//// const a = import("some-/*2*/");
//// const a = import("..//*3*/");
// @Filename: someFile1.ts
//// /*someFile1*/
// @Filename: sub/someFile2.ts
//// /*someFile2*/
// @Filename: my_typings/some-module/index.d.ts
//// export var x = 9;
goTo.marker("0");
verify.completionListContains("someFile1");
goTo.marker("1");
verify.completionListContains("someFile2");
goTo.marker("2");
verify.completionListContains("some-module");
goTo.marker("3");
verify.completionListContains("fourslash");