ci: add CI workflow + fix tsc strict union narrowing - #4
Conversation
CI workflow runs `bun install --frozen-lockfile`, `bunx tsc --noEmit`,
and shellcheck on bin/.
The api handlers used `c.req.json<T>().catch(() => ({}))` which produces
a `T | {}` union — strict tsc rejects property access on the empty
object. Annotated each `body` with the explicit `T` type so `{}` (which
is structurally assignable to a type whose props are all optional) lands
on the right branch.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
👋 CorvidAgent is looking into this. |
corvid-agent
left a comment
There was a problem hiding this comment.
LGTM — clean and correct.
CI workflow: Solid setup. shopt -s nullglob handles an empty bin/ gracefully, and the fail-flag pattern correctly accumulates errors rather than bailing on the first one. shellcheck ships with ubuntu-latest so no explicit install needed.
Type fixes: The explicit const body: T = ... annotation is the right fix for the T | {} union narrowing issue. All annotated properties are optional, so {} from the .catch() is structurally compatible — no runtime mismatch. The existing guard conditions (if (!body.source), if (!task), etc.) already handle the empty-object fallback path correctly.
One minor note for future: if a required property is ever added to one of these body types, the .catch(() => ({})) will silently produce a type-incompatible empty object (masked by the annotation). Consider using as T or a satisfies check if that becomes a concern — but for now with all-optional fields, this is correct.
Approving. 🪶
Summary
.github/workflows/ci.ymlrunning:bun install --frozen-lockfilebunx tsc --noEmit(strict typecheck)TS2339errors insrc/api.ts—await c.req.json<T>().catch(() => ({}))produces aT | {}union; strict tsc refused property access on the{}branch. Annotatedbodyvariables with the explicitTtype to land on the right branch.Test plan
bun install --frozen-lockfileclean locallybunx tsc --noEmitclean locally🤖 Generated with Claude Code