mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
De-dup typing module completions
This commit is contained in:
parent
db09a593d3
commit
e48312df54
@ -312,10 +312,11 @@ namespace ts.Completions.PathCompletions {
|
||||
|
||||
function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, span: TextSpan, result: CompletionEntry[] = []): CompletionEntry[] {
|
||||
// Check for typings specified in compiler options
|
||||
let seen = createMap<true>();
|
||||
if (options.types) {
|
||||
for (const typesName of options.types) {
|
||||
const moduleName = getPackageNameFromAtTypesDirectoryWithoutPrefix(typesName);
|
||||
result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span));
|
||||
pushResult(moduleName);
|
||||
}
|
||||
}
|
||||
else if (host.getDirectories) {
|
||||
@ -349,11 +350,18 @@ namespace ts.Completions.PathCompletions {
|
||||
typeDirectory = normalizePath(typeDirectory);
|
||||
const directoryName = getBaseFileName(typeDirectory);
|
||||
const moduleName = getPackageNameFromAtTypesDirectoryWithoutPrefix(directoryName);
|
||||
result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span));
|
||||
pushResult(moduleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function pushResult(moduleName: string) {
|
||||
if (!seen.has(moduleName)) {
|
||||
result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span));
|
||||
seen.set(moduleName, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function findPackageJsons(directory: string, host: LanguageServiceHost): string[] {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user