chore(scripts): type-check the deploy + secret-rotation tier via @ts-check#378
Conversation
|
Wondering what really moved? Review this PR in Change Stack to inspect semantic changes, definitions, and references. Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (15)
WalkthroughThis PR establishes TypeScript type-checking infrastructure for the Possibly related PRs
Comment |
|
agent-paste PR preview is ready. API: https://agent-paste-api-pr-378.isaac-a46.workers.dev |
…check Type-check the scripts/ decision-logic tier without converting .mjs to .ts (no transpile in the deploy hot path). Adds `// @ts-check` + a relaxed tsconfig.scripts.json (noImplicitAny off) over the deploy orchestrators and the pure scripts/lib/ modules, wired as `pnpm typecheck:scripts` into `pnpm verify` (and so into CI Validate). checkJs surfaced two real type smells in deploy.mjs, fixed in JSDoc with no runtime change: - buildProvisionPlan monkey-patched a `.missingProvider` array onto a Map; now declared via @type so the reader is type-safe. - fail() is annotated @returns {never} so the target-union guard narrows. Smoke/integration scripts are out of scope on purpose: they read `await res.json()` (typed unknown) throughout — all false positives on the same tier already excluded from unit coverage. Adding a file to the gate means giving it `// @ts-check` and listing it in tsconfig.scripts.json. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
69ed9be to
52b5b6a
Compare
|
agent-paste PR preview is ready. API: https://agent-paste-api-pr-378.isaac-a46.workers.dev |
|
agent-paste PR preview resources were cleaned up. The shared Preview GitHub Environment is retained for future preview deploys. |
What
Type-checks the
scripts/decision-logic tier without converting.mjsto.ts(no transpile in the deploy hot path). Adds// @ts-check+ a relaxedtsconfig.scripts.jsonover the deploy orchestrators and the purescripts/lib/modules, wired aspnpm typecheck:scriptsintopnpm verify— and therefore into CIValidate.This is the typing follow-up to the scripts coverage work (#373). Same scoping principle: gate the decision-logic tier, leave the integration scripts out.
Scope (11 files)
tsconfig.scripts.jsonlists exactly the files that opt in with// @ts-check:scripts/deploy.mjs,scripts/deploy-pr-preview.mjsscripts/lib/modules (rotation profiles/audit/engine, secret routing/values, env loaders, hyperdrive guard, wrangler env vars)Posture is deliberately relaxed vs
tsconfig.base.json(noImplicitAnyoff,strictoff) so un-annotated params don't force a.tsconversion. The goal is catching real bugs, not 100% annotation.Two real type smells found + fixed (deploy.mjs, JSDoc-only, no runtime change)
checkJsimmediately earned its keep on the production deploy path:buildProvisionPlanmonkey-patched a.missingProviderarray onto aMapinstance, then read it back inreportMissingProviderSecrets. Works at runtime, but untyped. Now declared via@type {Map<string, string[]> & { missingProvider?: string[] }}.fail()callsprocess.exit(1)but wasn't typed asnever, so thetargetunion guard didn't narrow and thecreateSecretPlanner({ target })call was a type error. Annotated@returns {never}.Why smoke/integration scripts are out of scope
They read
await res.json()(typedunknown) throughout — ~120 errors that are all false positives on the same tier already excluded from unit coverage invitest.scripts.config.ts. Forcing them to zero would mean casting every HTTP-response read across files we run viapnpm smoke:*, notpnpm test. To bring a file under the gate later: add// @ts-check, list it intsconfig.scripts.json, makepnpm typecheck:scriptspass.Verification
pnpm typecheck:scripts→ exit 0.mkdirSync(12345, { recursive: "yes" })into an in-scope file producesTS2769 No overload matches this call; file restores clean.pnpm test:scripts→ 168 tests pass (deploy + rotation covered).Policy documented in
scripts/README.md("Typing policy").🤖 Generated with Claude Code
Summary by CodeRabbit
Documentation
Chores