Enable TS strict mode and fix all associated errors

This commit is contained in:
William Oldham
2024-03-15 18:49:12 +00:00
parent a884c785f0
commit 8ba0544468
9 changed files with 28 additions and 21 deletions

View File

@@ -32,7 +32,7 @@ type Response<T> = BaseResponse<{
const mapBodyToFetchBody = (body: Request['body'], bodyType: Request['bodyType']): BodyInit => {
if (bodyType === 'FormData') {
const formData = new FormData();
body.forEach(([key, value]) => {
body.forEach(([key, value]: [any, any]) => {
formData.append(key, value.toString());
});
}
@@ -50,6 +50,9 @@ const mapBodyToFetchBody = (body: Request['body'], bodyType: Request['bodyType']
const handler: PlasmoMessaging.MessageHandler<Request, Response<any>> = async (req, res) => {
try {
if (!req.sender?.tab?.url) throw new Error('No tab URL found in the request.');
if (!req.body) throw new Error('No request body found in the request.');
const url = makeFullUrl(req.body.url, req.body);
await assertDomainWhitelist(req.sender.tab.url);
@@ -87,7 +90,7 @@ const handler: PlasmoMessaging.MessageHandler<Request, Response<any>> = async (r
finalUrl: response.url,
},
});
} catch (err) {
} catch (err: any) {
console.error('failed request', err);
res.send({
success: false,