Skip to content

Commit e084798

Browse files
committed
Fix newer TS errors
Signed-off-by: Simon Bennetts <psiinon@gmail.com>
1 parent c3e6ec9 commit e084798

File tree

6 files changed

+31
-11
lines changed

6 files changed

+31
-11
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020

2121
- name: Set Node.js environment
2222
uses: actions/setup-node@v4
23+
with:
24+
node-version: '20'
2325

2426
- name: Install dependencies
2527
run: yarn install

source/Background/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,19 @@ async function handleMessage(
262262
}
263263

264264
async function onMessageHandler(
265-
message: MessageEvent,
265+
message: unknown,
266266
_sender: Runtime.MessageSender
267267
): Promise<number | ZestScriptMessage> {
268268
let val: number | ZestScriptMessage = 2;
269269
const items = await Browser.storage.sync.get({
270270
zapurl: 'http://zap/',
271271
zapkey: 'not set',
272272
});
273-
const msg = await handleMessage(message, items.zapurl, items.zapkey);
273+
const msg = await handleMessage(
274+
message as MessageEvent,
275+
items.zapurl as string,
276+
items.zapkey as string
277+
);
274278
if (!(typeof msg === 'boolean')) {
275279
val = msg;
276280
}
@@ -286,7 +290,11 @@ function cookieChangeHandler(
286290
zapkey: 'not set',
287291
})
288292
.then((items) => {
289-
reportCookies(changeInfo.cookie, items.zapurl, items.zapkey);
293+
reportCookies(
294+
changeInfo.cookie,
295+
items.zapurl as string,
296+
items.zapkey as string
297+
);
290298
});
291299
}
292300

source/ContentScript/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,23 @@ function injectScript(): Promise<boolean> {
278278

279279
injectScript();
280280

281+
/* eslint-disable @typescript-eslint/no-explicit-any */
281282
Browser.runtime.onMessage.addListener(
282-
(message: MessageEvent, _sender: Runtime.MessageSender) => {
283+
(
284+
message: any,
285+
_sender: Runtime.MessageSender,
286+
_sendResponse: (response?: any) => void
287+
) => {
283288
if (message.type === ZAP_START_RECORDING) {
284289
configureExtension();
285290
recorder.recordUserInteractions();
286291
recorder.initializationScript();
287292
} else if (message.type === ZAP_STOP_RECORDING) {
288293
recorder.stopRecordingUserInteractions();
289294
}
295+
296+
// Returning `true` keeps the message channel open for async responses
297+
return true;
290298
}
291299
);
292300

source/Options/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ function restoreOptions(): void {
5454
})
5555
.then((items) => {
5656
(document.getElementById(ZAP_URL) as HTMLInputElement).value =
57-
items.zapurl;
57+
items.zapurl as string;
5858
(document.getElementById(ZAP_KEY) as HTMLInputElement).value =
59-
items.zapkey;
59+
items.zapkey as string;
6060
(document.getElementById(ZAP_ENABLE) as HTMLInputElement).checked =
61-
items.zapenable;
61+
items.zapenable as boolean;
6262
(
6363
document.getElementById('window-close-input') as HTMLInputElement
64-
).checked = items.zapclosewindowhandle;
64+
).checked = items.zapclosewindowhandle as boolean;
6565
});
6666
}
6767
document.addEventListener('DOMContentLoaded', restoreOptions);

source/Popup/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
ZAP_START_RECORDING,
3030
ZAP_STOP_RECORDING,
3131
} from '../utils/constants';
32+
import {ZestScriptMessage} from '../types/zestScript/ZestScript';
3233

3334
const STOP = i18n.t('stop');
3435
const START = i18n.t('start');
@@ -97,7 +98,7 @@ async function restoreState(): Promise<void> {
9798
} else {
9899
stoppedAnimation();
99100
}
100-
scriptNameInput.value = items.zapscriptname;
101+
scriptNameInput.value = items.zapscriptname as string;
101102
if (items.zapclosewindowhandle) {
102103
done?.classList.remove('invisible');
103104
} else {
@@ -189,7 +190,8 @@ async function handleSaveScript(): Promise<void> {
189190
await Browser.runtime.sendMessage({type: STOP_RECORDING});
190191
}
191192
Browser.runtime.sendMessage({type: SAVE_ZEST_SCRIPT}).then((items) => {
192-
downloadZestScript(items.script, items.title);
193+
const msg = items as ZestScriptMessage;
194+
downloadZestScript(msg.script, msg.title);
193195
});
194196
}
195197

source/types/zestScript/ZestScript.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class ZestScript {
9292
getZestScript(): Promise<ZestScriptMessage> {
9393
return new Promise((resolve) => {
9494
Browser.storage.sync.get({zapscriptname: this.title}).then((items) => {
95-
this.title = items.zapscriptname;
95+
this.title = items.zapscriptname as string;
9696
resolve({script: this.toJSON(), title: this.title});
9797
});
9898
});

0 commit comments

Comments
 (0)