Path completions for import types (#23082)

* Path completions

* Add missing flag to test

* Minify test, fix lint
This commit is contained in:
Wesley Wigham
2018-04-02 16:15:50 -07:00
committed by GitHub
parent 7eaad14bf9
commit fd553df3a6
3 changed files with 15 additions and 8 deletions

View File

@@ -380,6 +380,8 @@ namespace ts.Completions {
// }
// let x: Foo["/*completion position*/"]
return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode((node.parent.parent as IndexedAccessTypeNode).objectType));
case SyntaxKind.ImportTypeNode:
return { kind: StringLiteralCompletionKind.Paths, paths: PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) };
default:
return undefined;
}

View File

@@ -201,14 +201,6 @@ declare namespace FourSlashInterface {
assertHasRanges(ranges: Range[]): void;
caretAtMarker(markerName?: string): void;
completionsAt(markerName: string | ReadonlyArray<string>, completions: ReadonlyArray<string | { name: string, insertText?: string, replacementSpan?: Range }>, options?: CompletionsAtOptions): void;
completionsAndDetailsAt(
markerName: string,
completions: {
excludes?: ReadonlyArray<string>,
//TODO: better type
entries: ReadonlyArray<{ entry: any, details: any }>,
},
): void; //TODO: better type
applyCodeActionFromCompletion(markerName: string, options: {
name: string,
source?: string,

View File

@@ -0,0 +1,13 @@
/// <reference path="fourslash.ts" />
// @moduleResolution: node
// @Filename: /ns.ts
////file content not read
// @Filename: /node_modules/package/index.ts
////file content not read
// @Filename: /usage.ts
////type A = typeof import("p/*1*/");
////type B = typeof import(".//*2*/");
verify.completionsAt("1", ["package"], { isNewIdentifierLocation: true });
verify.completionsAt("2", ["lib", "ns", "node_modules"], { isNewIdentifierLocation: true });