Skip to content

Commit fd553df

Browse files
authored
Path completions for import types (#23082)
* Path completions * Add missing flag to test * Minify test, fix lint
1 parent 7eaad14 commit fd553df

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

src/services/completions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ namespace ts.Completions {
380380
// }
381381
// let x: Foo["/*completion position*/"]
382382
return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode((node.parent.parent as IndexedAccessTypeNode).objectType));
383+
case SyntaxKind.ImportTypeNode:
384+
return { kind: StringLiteralCompletionKind.Paths, paths: PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) };
383385
default:
384386
return undefined;
385387
}

tests/cases/fourslash/fourslash.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,6 @@ declare namespace FourSlashInterface {
201201
assertHasRanges(ranges: Range[]): void;
202202
caretAtMarker(markerName?: string): void;
203203
completionsAt(markerName: string | ReadonlyArray<string>, completions: ReadonlyArray<string | { name: string, insertText?: string, replacementSpan?: Range }>, options?: CompletionsAtOptions): void;
204-
completionsAndDetailsAt(
205-
markerName: string,
206-
completions: {
207-
excludes?: ReadonlyArray<string>,
208-
//TODO: better type
209-
entries: ReadonlyArray<{ entry: any, details: any }>,
210-
},
211-
): void; //TODO: better type
212204
applyCodeActionFromCompletion(markerName: string, options: {
213205
name: string,
214206
source?: string,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @moduleResolution: node
4+
5+
// @Filename: /ns.ts
6+
////file content not read
7+
// @Filename: /node_modules/package/index.ts
8+
////file content not read
9+
// @Filename: /usage.ts
10+
////type A = typeof import("p/*1*/");
11+
////type B = typeof import(".//*2*/");
12+
verify.completionsAt("1", ["package"], { isNewIdentifierLocation: true });
13+
verify.completionsAt("2", ["lib", "ns", "node_modules"], { isNewIdentifierLocation: true });

0 commit comments

Comments
 (0)