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;
for (const r of titleRows) {
const canonical = canonicalByLang.get(r.language);
const canonical = canonicalByLang.get(r.language) ?? null;
if (r.title === canonical) continue;
// 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 ─────────────────────────────────────────────────────────────
// All non-API routes serve the React index.html so TanStack Router handles them.
app.get("*", (c) => {
const _accept = c.req.header("Accept") ?? "";
app.get("*", async (c) => {
if (c.req.path.startsWith("/api/")) return c.notFound();
// In dev the Vite server handles the SPA. In production serve dist/index.html.
try {
const html = Bun.file("./dist/index.html").text();
return html.then((text) => c.html(text));
const html = await Bun.file("./dist/index.html").text();
return c.html(html);
} catch {
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": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"jsx": "react-jsx",
"strict": true,
"skipLibCheck": true,
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"baseUrl": ".",
"paths": {
"~/*": ["./src/*"]
}
},
"include": ["src/**/*", "vite.config.ts"]
"files": [],
"references": [
{ "path": "./tsconfig.client.json" },
{ "path": "./tsconfig.server.json" }
]
}