Skip to content

Commit 7d1f0e6

Browse files
authored
use local registry to check if typings package exist (#12014) (#12032)
use local registry to check if typings package exist
1 parent 0b87210 commit 7d1f0e6

File tree

4 files changed

+208
-274
lines changed

4 files changed

+208
-274
lines changed

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ namespace ts.projectSystem {
1818
};
1919

2020
export interface PostExecAction {
21-
readonly requestKind: TI.RequestKind;
2221
readonly success: boolean;
2322
readonly callback: TI.RequestCompletedAction;
2423
}
@@ -47,9 +46,13 @@ namespace ts.projectSystem {
4746

4847
export class TestTypingsInstaller extends TI.TypingsInstaller implements server.ITypingsInstaller {
4948
protected projectService: server.ProjectService;
50-
constructor(readonly globalTypingsCacheLocation: string, throttleLimit: number, readonly installTypingHost: server.ServerHost, log?: TI.Log) {
51-
super(globalTypingsCacheLocation, safeList.path, throttleLimit, log);
52-
this.init();
49+
constructor(
50+
readonly globalTypingsCacheLocation: string,
51+
throttleLimit: number,
52+
installTypingHost: server.ServerHost,
53+
readonly typesRegistry = createMap<void>(),
54+
log?: TI.Log) {
55+
super(installTypingHost, globalTypingsCacheLocation, safeList.path, throttleLimit, log);
5356
}
5457

5558
safeFileList = safeList.path;
@@ -63,9 +66,8 @@ namespace ts.projectSystem {
6366
}
6467
}
6568

66-
checkPendingCommands(expected: TI.RequestKind[]) {
67-
assert.equal(this.postExecActions.length, expected.length, `Expected ${expected.length} post install actions`);
68-
this.postExecActions.forEach((act, i) => assert.equal(act.requestKind, expected[i], "Unexpected post install action"));
69+
checkPendingCommands(expectedCount: number) {
70+
assert.equal(this.postExecActions.length, expectedCount, `Expected ${expectedCount} post install actions`);
6971
}
7072

7173
onProjectClosed() {
@@ -79,15 +81,8 @@ namespace ts.projectSystem {
7981
return this.installTypingHost;
8082
}
8183

82-
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
83-
switch (requestKind) {
84-
case TI.NpmViewRequest:
85-
case TI.NpmInstallRequest:
86-
break;
87-
default:
88-
assert.isTrue(false, `request ${requestKind} is not supported`);
89-
}
90-
this.addPostExecAction(requestKind, "success", cb);
84+
installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
85+
this.addPostExecAction("success", cb);
9186
}
9287

9388
sendResponse(response: server.SetTypings | server.InvalidateCachedTypings) {
@@ -99,12 +94,11 @@ namespace ts.projectSystem {
9994
this.install(request);
10095
}
10196

102-
addPostExecAction(requestKind: TI.RequestKind, stdout: string | string[], cb: TI.RequestCompletedAction) {
97+
addPostExecAction(stdout: string | string[], cb: TI.RequestCompletedAction) {
10398
const out = typeof stdout === "string" ? stdout : createNpmPackageJsonString(stdout);
10499
const action: PostExecAction = {
105100
success: !!out,
106-
callback: cb,
107-
requestKind
101+
callback: cb
108102
};
109103
this.postExecActions.push(action);
110104
}

0 commit comments

Comments
 (0)