Skip to content

Commit aff02e8

Browse files
Move createTypesRegistry so more accessible
1 parent 2a0d5d1 commit aff02e8

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,25 @@ namespace ts.projectSystem {
126126
return JSON.stringify({ dependencies });
127127
}
128128

129+
export function createTypesRegistry(...list: string[]): Map<MapLike<string>> {
130+
const versionMap = {
131+
"latest": "1.3.0",
132+
"ts2.0": "1.0.0",
133+
"ts2.1": "1.0.0",
134+
"ts2.2": "1.2.0",
135+
"ts2.3": "1.3.0",
136+
"ts2.4": "1.3.0",
137+
"ts2.5": "1.3.0",
138+
"ts2.6": "1.3.0",
139+
"ts2.7": "1.3.0"
140+
};
141+
const map = createMap<MapLike<string>>();
142+
for (const l of list) {
143+
map.set(l, versionMap);
144+
}
145+
return map;
146+
}
147+
129148
export function toExternalFile(fileName: string): protocol.ExternalFile {
130149
return { fileName };
131150
}
@@ -6528,12 +6547,18 @@ namespace ts.projectSystem {
65286547
},
65296548
})
65306549
};
6550+
const typingsCachePackageLockJson: FileOrFolder = {
6551+
path: `${typingsCache}/package-lock.json`,
6552+
content: JSON.stringify({
6553+
dependencies: {
6554+
},
6555+
})
6556+
};
65316557

6532-
const files = [file, packageJsonInCurrentDirectory, packageJsonOfPkgcurrentdirectory, indexOfPkgcurrentdirectory, typingsCachePackageJson];
6558+
const files = [file, packageJsonInCurrentDirectory, packageJsonOfPkgcurrentdirectory, indexOfPkgcurrentdirectory, typingsCachePackageJson, typingsCachePackageLockJson];
65336559
const host = createServerHost(files, { currentDirectory });
65346560

6535-
const typesRegistry = createMap<MapLike<string>>();
6536-
typesRegistry.set("pkgcurrentdirectory", void 0);
6561+
const typesRegistry = createTypesRegistry("pkgcurrentdirectory");
65376562
const typingsInstaller = new TestTypingsInstaller(typingsCache, /*throttleLimit*/ 5, host, typesRegistry);
65386563

65396564
const projectService = createProjectService(host, { typingsInstaller });

src/harness/unittests/typingsInstaller.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,6 @@ namespace ts.projectSystem {
1414
typesRegistry?: Map<MapLike<string>>;
1515
}
1616

17-
function createTypesRegistry(...list: string[]): Map<MapLike<string>> {
18-
const versionMap = {
19-
"latest": "1.3.0",
20-
"ts2.0": "1.0.0",
21-
"ts2.1": "1.0.0",
22-
"ts2.2": "1.2.0",
23-
"ts2.3": "1.3.0",
24-
"ts2.4": "1.3.0",
25-
"ts2.5": "1.3.0",
26-
"ts2.6": "1.3.0",
27-
"ts2.7": "1.3.0"
28-
};
29-
const map = createMap<MapLike<string>>();
30-
for (const l of list) {
31-
map.set(l, versionMap);
32-
}
33-
return map;
34-
}
35-
3617
class Installer extends TestTypingsInstaller {
3718
constructor(host: server.ServerHost, p?: InstallerParams, log?: TI.Log) {
3819
super(

0 commit comments

Comments
 (0)