fix server typecheck: use tsconfig project references, await bun file in spa fallback
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled

- split tsconfig.json into project references (client + server) so bun-types and DOM types don't leak into the other side; server now resolves Bun.* without diagnostics
- client tsconfig adds vite/client types so import.meta.env typechecks
- index.tsx spa fallback: use async/await + c.html(await …) instead of returning a Promise of a Response, which Hono's Handler type rejects
- subtitles normalize-titles: narrow canonical to string|null (Map.get widened to include undefined)
This commit is contained in:
2026-04-13 07:51:10 +02:00
parent 874f04b7a5
commit af410cb616
5 changed files with 28 additions and 19 deletions

View File

@@ -594,7 +594,7 @@ app.post("/normalize-titles", (c) => {
let normalized = 0; let normalized = 0;
for (const r of titleRows) { for (const r of titleRows) {
const canonical = canonicalByLang.get(r.language); const canonical = canonicalByLang.get(r.language) ?? null;
if (r.title === canonical) continue; if (r.title === canonical) continue;
// Find all streams matching this language+title and set custom_title on their decisions // Find all streams matching this language+title and set custom_title on their decisions

View File

@@ -49,13 +49,12 @@ app.use("/favicon.ico", serveStatic({ path: "./dist/favicon.ico" }));
// ─── SPA fallback ───────────────────────────────────────────────────────────── // ─── SPA fallback ─────────────────────────────────────────────────────────────
// All non-API routes serve the React index.html so TanStack Router handles them. // All non-API routes serve the React index.html so TanStack Router handles them.
app.get("*", (c) => { app.get("*", async (c) => {
const _accept = c.req.header("Accept") ?? "";
if (c.req.path.startsWith("/api/")) return c.notFound(); if (c.req.path.startsWith("/api/")) return c.notFound();
// In dev the Vite server handles the SPA. In production serve dist/index.html. // In dev the Vite server handles the SPA. In production serve dist/index.html.
try { try {
const html = Bun.file("./dist/index.html").text(); const html = await Bun.file("./dist/index.html").text();
return html.then((text) => c.html(text)); return c.html(html);
} catch { } catch {
return c.text("Run `bun build` first to generate the frontend.", 503); return c.text("Run `bun build` first to generate the frontend.", 503);
} }

18
tsconfig.client.json Normal file
View File

@@ -0,0 +1,18 @@
{
"compilerOptions": {
"composite": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"jsx": "react-jsx",
"strict": true,
"skipLibCheck": true,
"types": ["vite/client"],
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"baseUrl": ".",
"paths": {
"~/*": ["./src/*"]
}
},
"include": ["src/**/*", "vite.config.ts"]
}

File diff suppressed because one or more lines are too long

View File

@@ -1,16 +1,7 @@
{ {
"compilerOptions": { "files": [],
"target": "ESNext", "references": [
"module": "ESNext", { "path": "./tsconfig.client.json" },
"moduleResolution": "bundler", { "path": "./tsconfig.server.json" }
"jsx": "react-jsx", ]
"strict": true,
"skipLibCheck": true,
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"baseUrl": ".",
"paths": {
"~/*": ["./src/*"]
}
},
"include": ["src/**/*", "vite.config.ts"]
} }