From aff02e879cde1e614526fa044f1f09f456542765 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Thu, 11 Jan 2018 13:20:45 -0800 Subject: [PATCH] Move createTypesRegistry so more accessible --- .../unittests/tsserverProjectSystem.ts | 31 +++++++++++++++++-- src/harness/unittests/typingsInstaller.ts | 19 ------------ 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 279bec7db04..90c38186828 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -126,6 +126,25 @@ namespace ts.projectSystem { return JSON.stringify({ dependencies }); } + export function createTypesRegistry(...list: string[]): Map> { + const versionMap = { + "latest": "1.3.0", + "ts2.0": "1.0.0", + "ts2.1": "1.0.0", + "ts2.2": "1.2.0", + "ts2.3": "1.3.0", + "ts2.4": "1.3.0", + "ts2.5": "1.3.0", + "ts2.6": "1.3.0", + "ts2.7": "1.3.0" + }; + const map = createMap>(); + for (const l of list) { + map.set(l, versionMap); + } + return map; + } + export function toExternalFile(fileName: string): protocol.ExternalFile { return { fileName }; } @@ -6528,12 +6547,18 @@ namespace ts.projectSystem { }, }) }; + const typingsCachePackageLockJson: FileOrFolder = { + path: `${typingsCache}/package-lock.json`, + content: JSON.stringify({ + dependencies: { + }, + }) + }; - const files = [file, packageJsonInCurrentDirectory, packageJsonOfPkgcurrentdirectory, indexOfPkgcurrentdirectory, typingsCachePackageJson]; + const files = [file, packageJsonInCurrentDirectory, packageJsonOfPkgcurrentdirectory, indexOfPkgcurrentdirectory, typingsCachePackageJson, typingsCachePackageLockJson]; const host = createServerHost(files, { currentDirectory }); - const typesRegistry = createMap>(); - typesRegistry.set("pkgcurrentdirectory", void 0); + const typesRegistry = createTypesRegistry("pkgcurrentdirectory"); const typingsInstaller = new TestTypingsInstaller(typingsCache, /*throttleLimit*/ 5, host, typesRegistry); const projectService = createProjectService(host, { typingsInstaller }); diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index 1e0a66f6d55..33f3544bde8 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -14,25 +14,6 @@ namespace ts.projectSystem { typesRegistry?: Map>; } - function createTypesRegistry(...list: string[]): Map> { - const versionMap = { - "latest": "1.3.0", - "ts2.0": "1.0.0", - "ts2.1": "1.0.0", - "ts2.2": "1.2.0", - "ts2.3": "1.3.0", - "ts2.4": "1.3.0", - "ts2.5": "1.3.0", - "ts2.6": "1.3.0", - "ts2.7": "1.3.0" - }; - const map = createMap>(); - for (const l of list) { - map.set(l, versionMap); - } - return map; - } - class Installer extends TestTypingsInstaller { constructor(host: server.ServerHost, p?: InstallerParams, log?: TI.Log) { super(