Skip to content

Commit

Permalink
Update to TypeScript 5.0
Browse files Browse the repository at this point in the history
Incldues also running linting and tsc checks over the worker.

Not upgrading to 5.1 yet because the ESLint plugin has not been updated
for it yet (typescript-eslint/typescript-eslint#6934).
  • Loading branch information
mihaip committed Jun 2, 2023
1 parent de8815d commit 9f798a7
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 105 deletions.
188 changes: 94 additions & 94 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"ringbuf.js": "^0.3.3",
"typescript": "^4.1.2"
"typescript": "^5.0.4"
},
"devDependencies": {
"@types/audioworklet": "^0.0.46",
Expand Down Expand Up @@ -44,8 +44,8 @@
"worker-dev": "wrangler dev --local --port=3128",
"worker-deploy": "wrangler publish --env production",
"prettier": "prettier --write src workers-site",
"lint": "eslint src",
"check": "tsc --noEmit",
"lint": "eslint --fix src workers-site",
"check": "tsc --noEmit && tsc --noEmit --project workers-site/tsconfig.json",
"format-macemu": "clang-format -i --glob=macemu/BasiliskII/src/Unix/JS/*"
},
"eslintConfig": {
Expand Down
2 changes: 1 addition & 1 deletion workers-site/cd-rom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export async function handleRequest(request: Request) {
status: 200,
headers: {
"Content-Type": "multipart/mixed",
"Content-Length": srcRes.headers.get("Content-Length"),
"Content-Length": srcRes.headers.get("Content-Length")!,
// Always allow caching (mirrors logic for our own disk chunks).
"Cache-Control": `public, max-age=${60 * 60 * 24 * 30}, immutable`,
},
Expand Down
3 changes: 2 additions & 1 deletion workers-site/ethernet-zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class EthernetZone implements DurableObject {
case "close":
this.closeClient(client);
break;
case "send":
case "send": {
const {destination, ...sendPayload} = payload;
for (const otherClient of this.#clients) {
if (otherClient === client || otherClient.closed) {
Expand All @@ -86,6 +86,7 @@ export class EthernetZone implements DurableObject {
}
}
break;
}
default:
console.warn("Unexpected message", data);
}
Expand Down
11 changes: 7 additions & 4 deletions workers-site/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as varz from "./varz";
import * as cdrom from "./cd-rom";
import {getAssetFromKV} from "@cloudflare/kv-asset-handler";
// @ts-expect-error
// @ts-expect-error TODO: include declaration for this generated module.
import manifestJSON from "__STATIC_CONTENT_MANIFEST";
const manifest = JSON.parse(manifestJSON);

Expand Down Expand Up @@ -105,9 +105,12 @@ async function handleRequest(
...notFoundResponse,
status: 404,
});
} catch (e) {}
} catch (e) {
// Ignored
}

return new Response(e.message || e.toString(), {status: 500});
const err = e as Error;
return new Response(err.message || err.toString(), {status: 500});
}
}

Expand Down Expand Up @@ -136,7 +139,7 @@ function mapRequestToAsset(request: Request): Request {
return new Request(parsedUrl.toString(), request);
}

const LEGACY_DOMAINS = {
const LEGACY_DOMAINS: {[domain: string]: string} = {
"system6.app": "/1991/System%206.0.8",
"system7.app": "/1996/System%207.5.3",
"kanjitalk7.app": "/1996/KanjiTalk%207.5.3",
Expand Down
3 changes: 2 additions & 1 deletion workers-site/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"target": "ES2020",
"module": "CommonJS",
"lib": ["ES2020"],
"types": ["@cloudflare/workers-types"]
"types": ["@cloudflare/workers-types"],
"strict": true
}
}
4 changes: 3 additions & 1 deletion workers-site/varz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export async function handleRequest(request: Request, namespace: KVNamespace) {
type: "json",
cacheTtl: 60,
})) ?? {};
const varzsSorted = Object.fromEntries(Object.entries(varzs).sort());
const varzsSorted = Object.fromEntries(
Object.entries(varzs).sort((a, b) => (a[0] < b[0] ? -1 : 1))
);
return new Response(JSON.stringify(varzsSorted, undefined, 4), {
status: 200,
headers: {
Expand Down

0 comments on commit 9f798a7

Please sign in to comment.