Skip to content

Commit 9870318

Browse files
committed
chore(SRI-NA): pin jest/ts-jest/typescript; relax service handler typing to fix build
1 parent a4485eb commit 9870318

File tree

4 files changed

+1084
-1079
lines changed

4 files changed

+1084
-1079
lines changed

package.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
"version": "1.0.3",
44
"license": "Apache-2.0",
55
"description": "Scheme-based implementations of Source, written in Typescript",
6-
"keywords": ["Scheme", "interpreter", "compiler", "Source", "SICP"],
6+
"keywords": [
7+
"Scheme",
8+
"interpreter",
9+
"compiler",
10+
"Source",
11+
"SICP"
12+
],
713
"author": {
814
"name": "Source Academy",
915
"url": "https://github.com/source-academy/"
@@ -42,7 +48,7 @@
4248
"@rollup/plugin-commonjs": "^28.0.3",
4349
"@rollup/plugin-node-resolve": "^16.0.1",
4450
"@rollup/plugin-typescript": "^12.1.2",
45-
"@types/jest": "^30.0.0",
51+
"@types/jest": "^29.5.12",
4652
"@types/node": "^22.15.30",
4753
"@typescript-eslint/eslint-plugin": "^6.4.0",
4854
"babel-jest": "^30.0.2",
@@ -53,13 +59,13 @@
5359
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
5460
"eslint-plugin-promise": "^6.6.0",
5561
"husky": "^9.1.7",
56-
"jest": "^30.0.4",
62+
"jest": "^29.7.0",
5763
"jest-util": "^30.0.5",
5864
"prettier": "^3.5.3",
5965
"rollup": "^4.38.0",
6066
"source-map": "^0.7.4",
61-
"ts-jest": "^29.4.0",
67+
"ts-jest": "^29.1.2",
6268
"tslib": "^2.8.1",
63-
"typescript": "*"
69+
"typescript": "^5.4.5"
6470
}
6571
}

src/conductor/host/BasicHostPlugin.ts

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,50 +39,43 @@ export abstract class BasicHostPlugin implements IHostPlugin {
3939

4040
private __chunkCount: number = 0;
4141

42-
// @ts-expect-error TODO: figure proper way to typecheck this
4342
private readonly __serviceHandlers = new Map<
4443
ServiceMessageType,
45-
(message: IServiceMessage) => void
44+
(message: any) => void
4645
>([
4746
[
4847
ServiceMessageType.HELLO,
49-
function helloServiceHandler(
50-
this: BasicHostPlugin,
51-
message: HelloServiceMessage
52-
) {
53-
if (message.data.version < Constant.PROTOCOL_MIN_VERSION) {
48+
(message: any) => {
49+
const hello = message as HelloServiceMessage;
50+
if (hello.data.version < Constant.PROTOCOL_MIN_VERSION) {
5451
this.__serviceChannel.send(
5552
new AbortServiceMessage(Constant.PROTOCOL_MIN_VERSION)
5653
);
5754
console.error(
58-
`Runner's protocol version (${message.data.version}) must be at least ${Constant.PROTOCOL_MIN_VERSION}`
55+
`Runner's protocol version (${hello.data.version}) must be at least ${Constant.PROTOCOL_MIN_VERSION}`
5956
);
6057
} else {
6158
console.log(
62-
`Runner is using protocol version ${message.data.version}`
59+
`Runner is using protocol version ${hello.data.version}`
6360
);
6461
}
6562
},
6663
],
6764
[
6865
ServiceMessageType.ABORT,
69-
function abortServiceHandler(
70-
this: BasicHostPlugin,
71-
message: AbortServiceMessage
72-
) {
66+
(message: any) => {
67+
const abort = message as AbortServiceMessage;
7368
console.error(
74-
`Runner expects at least protocol version ${message.data.minVersion}, but we are on version ${Constant.PROTOCOL_VERSION}`
69+
`Runner expects at least protocol version ${abort.data.minVersion}, but we are on version ${Constant.PROTOCOL_VERSION}`
7570
);
7671
this.__conduit.terminate();
7772
},
7873
],
7974
[
8075
ServiceMessageType.PLUGIN,
81-
function pluginServiceHandler(
82-
this: BasicHostPlugin,
83-
message: PluginServiceMessage
84-
) {
85-
const pluginName = message.data;
76+
(message: any) => {
77+
const pluginMsg = message as PluginServiceMessage;
78+
const pluginName = pluginMsg.data;
8679
this.requestLoadPlugin(pluginName);
8780
},
8881
],

src/conductor/runner/RunnerPlugin.ts

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,48 +57,41 @@ export class RunnerPlugin implements IRunnerPlugin {
5757
private readonly __errorChannel: IChannel<IErrorMessage>;
5858
private readonly __statusChannel: IChannel<IStatusMessage>;
5959

60-
// @ts-expect-error TODO: figure proper way to typecheck this
6160
private readonly __serviceHandlers = new Map<
6261
ServiceMessageType,
63-
(message: IServiceMessage) => void
62+
(message: any) => void
6463
>([
6564
[
6665
ServiceMessageType.HELLO,
67-
function helloServiceHandler(
68-
this: RunnerPlugin,
69-
message: HelloServiceMessage
70-
) {
71-
if (message.data.version < Constant.PROTOCOL_MIN_VERSION) {
66+
(message: any) => {
67+
const hello = message as HelloServiceMessage;
68+
if (hello.data.version < Constant.PROTOCOL_MIN_VERSION) {
7269
this.__serviceChannel.send(
7370
new AbortServiceMessage(Constant.PROTOCOL_MIN_VERSION)
7471
);
7572
console.error(
76-
`Host's protocol version (${message.data.version}) must be at least ${Constant.PROTOCOL_MIN_VERSION}`
73+
`Host's protocol version (${hello.data.version}) must be at least ${Constant.PROTOCOL_MIN_VERSION}`
7774
);
7875
} else {
79-
console.log(`Host is using protocol version ${message.data.version}`);
76+
console.log(`Host is using protocol version ${hello.data.version}`);
8077
}
8178
},
8279
],
8380
[
8481
ServiceMessageType.ABORT,
85-
function abortServiceHandler(
86-
this: RunnerPlugin,
87-
message: AbortServiceMessage
88-
) {
82+
(message: any) => {
83+
const abort = message as AbortServiceMessage;
8984
console.error(
90-
`Host expects at least protocol version ${message.data.minVersion}, but we are on version ${Constant.PROTOCOL_VERSION}`
85+
`Host expects at least protocol version ${abort.data.minVersion}, but we are on version ${Constant.PROTOCOL_VERSION}`
9186
);
9287
this.__conduit.terminate();
9388
},
9489
],
9590
[
9691
ServiceMessageType.ENTRY,
97-
function entryServiceHandler(
98-
this: RunnerPlugin,
99-
message: EntryServiceMessage
100-
) {
101-
this.__evaluator.startEvaluator(message.data);
92+
(message: any) => {
93+
const entry = message as EntryServiceMessage;
94+
this.__evaluator.startEvaluator(entry.data);
10295
},
10396
],
10497
]);

0 commit comments

Comments
 (0)