mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 10:46:28 -05:00
Path completions for import types (#23082)
* Path completions * Add missing flag to test * Minify test, fix lint
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
13
tests/cases/fourslash/importTypeModuleCompletions.ts
Normal file
13
tests/cases/fourslash/importTypeModuleCompletions.ts
Normal 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 });
|
||||
Reference in New Issue
Block a user