Fix the backend build against hono's narrowed route param type. #34

Merged
Michilis merged 1 commits from dev into main 2026-08-23 06:16:27 +00:00
Owner

npm audit fix floated hono from 4.4 to 4.11 within the ^4.4.7 range and
tsc stopped compiling. c.req.param(key) has two overloads: it returns
string only when the route path's literal type survives inference, and
string | undefined otherwise. requireAuth() returns a handler annotated
with a bare Context, which erases the path generic, so every param read
behind it is now string | undefined.

Only four sites failed. Everywhere else the value lands in
eq((table as any).id, ...), where the any swallows it. Routes that also
run zValidator kept their typing, since that middleware is generic and
restores the inference -- door.ts:251 compiles while the two plain
requireAuth routes beside it do not.

loadEvent now accepts string | undefined and returns null for a missing
id, which both door callers already handle with their 404 branch. The
payments and tickets handlers pass the id off the row they just fetched
and null-checked rather than the raw param.

This leaves the underlying erasure in place. Typing requireAuth to
preserve the path generic would restore string on every authed route,
but it touches all of them and belongs in its own change.

npm audit fix floated hono from 4.4 to 4.11 within the ^4.4.7 range and tsc stopped compiling. c.req.param(key) has two overloads: it returns string only when the route path's literal type survives inference, and string | undefined otherwise. requireAuth() returns a handler annotated with a bare Context, which erases the path generic, so every param read behind it is now string | undefined. Only four sites failed. Everywhere else the value lands in eq((table as any).id, ...), where the any swallows it. Routes that also run zValidator kept their typing, since that middleware is generic and restores the inference -- door.ts:251 compiles while the two plain requireAuth routes beside it do not. loadEvent now accepts string | undefined and returns null for a missing id, which both door callers already handle with their 404 branch. The payments and tickets handlers pass the id off the row they just fetched and null-checked rather than the raw param. This leaves the underlying erasure in place. Typing requireAuth to preserve the path generic would restore string on every authed route, but it touches all of them and belongs in its own change.
Michilis added 1 commit 2026-08-23 06:16:17 +00:00
npm audit fix floated hono from 4.4 to 4.11 within the ^4.4.7 range and
tsc stopped compiling. c.req.param(key) has two overloads: it returns
string only when the route path's literal type survives inference, and
string | undefined otherwise. requireAuth() returns a handler annotated
with a bare Context, which erases the path generic, so every param read
behind it is now string | undefined.

Only four sites failed. Everywhere else the value lands in
eq((table as any).id, ...), where the any swallows it. Routes that also
run zValidator kept their typing, since that middleware is generic and
restores the inference -- door.ts:251 compiles while the two plain
requireAuth routes beside it do not.

loadEvent now accepts string | undefined and returns null for a missing
id, which both door callers already handle with their 404 branch. The
payments and tickets handlers pass the id off the row they just fetched
and null-checked rather than the raw param.

This leaves the underlying erasure in place. Typing requireAuth to
preserve the path generic would restore string on every authed route,
but it touches all of them and belongs in its own change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Michilis merged commit 279cd19308 into main 2026-08-23 06:16:27 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Michilis/Spanglish#34