From 2236d77214a2995e76c3c7e0fdc359b4359d011c Mon Sep 17 00:00:00 2001 From: pagoru Date: Tue, 19 Mar 2024 01:08:15 +0100 Subject: [PATCH] wip --- debug.ts | 5 +++-- src/utils.ts | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/debug.ts b/debug.ts index f6c814a..ec5a213 100644 --- a/debug.ts +++ b/debug.ts @@ -19,7 +19,7 @@ export const serveGame = async () => { socketClientList.length })`, ); - socketClientList.forEach((ws: WebSocket) => ws.send(JSON.stringify(data))); + socketClientList.forEach((ws: WebSocket | undefined) => ws?.send(JSON.stringify(data))); }; { @@ -52,6 +52,7 @@ export const serveGame = async () => { sendMessageToClients({ type: 'reload' }); return new Response(); case '/_hotSwap': + if(!request.body) break; const reader = request.body.getReader(); let text = ''; while (true) { @@ -69,7 +70,7 @@ export const serveGame = async () => { sendMessageToClients({ type: 'hotSwap', - data: list.map(({ name, mtime, globalReference }) => ({ + data: list.map(({ name, mtime, globalReference }: any) => ({ name, mtime, globalReference, diff --git a/src/utils.ts b/src/utils.ts index 4b6aae5..3cfa89e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -71,7 +71,7 @@ export const bundle = ( plugins: string[], ) => { const environments = JSON.parse(envs).reduce( - (obj, key) => ({ ...obj, [key]: Deno.env.get(key) }), + (obj: any, key: any) => ({ ...obj, [key]: Deno.env.get(key) }), {}, ); const command = new Deno.Command(Deno.execPath(), { @@ -145,7 +145,7 @@ export const getBuildArgs = ({ }; export const getFileList = async () => { - const fileList = {}; + const fileList: any = {}; const _getFileList = async (dirname: string) => { for await (const dirEntry of Deno.readDir(dirname)) { const entryPath = `${dirname}/${dirEntry.name}`; @@ -163,7 +163,7 @@ export const getFileList = async () => { return fileList; }; -export const getObjectComparison = (obj1, obj2) => { +export const getObjectComparison = (obj1: any, obj2: any) => { let keys1 = Object.keys(obj1); let keys2 = Object.keys(obj2); @@ -171,12 +171,12 @@ export const getObjectComparison = (obj1, obj2) => { let addedKeys = keys2.filter(key => !keys1.includes(key)); - let modifiedValues = keys1.reduce((acc, key) => { + let modifiedValues = keys1.reduce((acc: any, key) => { if (keys2.includes(key) && obj1[key] !== obj2[key]) { acc[key] = { old: obj1[key], new: obj2[key] }; } return acc; - }, {}); + }, {} as any); return { deletedKeys, modifiedValues, addedKeys }; };