Repository navigation
test(builds): cast the env DB before binding batch - #834
Merged
Merged
Conversation
Rebased onto main as a single change: #832 squash-merged the behaviour fix, so only the type correction remains. makeEnv() types DB as { prepare }, so env.DB.batch fails TS2339 and the worker build stops at Run checks. Cast through D1Database, following the existing feedback-commit shim in the same file. No behaviour change. tsc clean on those lines; worker suite 1201 passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Main does not type-check. The deploy gate failed with:
The batch shims added with #832 call
env.DB.batch, butmakeEnv()types the database as{ prepare }only. Vitest does not run these checks, so the suites were green while the worker build was red.This replaces #833, whose branch still carried the pre-squash commits from #832 and therefore conflicted; this is the same change as a single commit on current main.
Changes
Cast through
D1Databasebefore bindingbatch, following the existing feedback-commit shim in the same file. Two lines, no behaviour change.Testing
tsc --noEmitreports nothing on those lines.Follow-up
Worth stating because it cost a failed deploy:
worker-tests.ymldocuments that the worker type-check is deliberately not run at pull-request time — it needsworker-configuration.d.tsgenerated from the rendered production config. So a green PR is not evidence that main builds forworker/srcorworker/testchanges; the deploy gate is the only check, which means dispatching a deploy soon after merge is what surfaces a type error.Codex suggested closing that gap in PR CI by generating
wrangler typesfrom a placeholder config and then runningtsc --noEmit. Two type errors today (TS2532, then this one) were both found only at deploy time, so that step would have caught both.