Skip to content

Type-check script/, worker/, e2e/, and tool configs - #2030

Merged
benbalter merged 1 commit into
mainfrom
audit-typecheck-tooling
Sep 27, 2026
Merged

benbalter merged 1 commit into
mainfrom
audit-typecheck-tooling

Conversation

@benbalter

Copy link
Copy Markdown
Owner

tsconfig.astro.json only includes src/ and astro.config.mjs, so astro check never type-checked script/**/*.ts, worker/*.js, e2e/, vitest.config.ts, or playwright.config.ts.

Changes

  • New tsconfig.tooling.json: strict, noEmit, module: ESNext + moduleResolution: bundler (matches how tsx runs the extensionless-import scripts), Node types, DOM lib for Playwright page code and the Worker's Request/Response, and allowJs + checkJs for worker/. No new deps: the worker's existing JSDoc types are enough, so @cloudflare/workers-types isn't needed.
  • Named tsconfig.tooling.json rather than tsconfig.json on purpose. Vite/esbuild and the Astro language server resolve the nearest tsconfig.json, so a root one would start governing src/ transforms and editor checks.
  • npm run check:tooling (tsc -p tsconfig.tooling.json), added to npm test and as a step in the ci.yml check job. Left out of build-and-deploy.yml; CI already gates PRs.
  • Removed the stale _site exclude from tsconfig.astro.json.

Errors found

7 errors before fixes. None were real runtime bugs:

  • e2e/link-validation.spec.ts: unused fs/path imports.
  • script/standard-site/sync-document.ts: DocumentRecord interface isn't assignable to putRecord's { [x: string]: unknown } record param. Switched to a type alias (identical shape).
  • worker/index.test.js: implicit any on test helpers, plus the ASSETS.fetch mock took only Request while the worker's env type says typeof fetch. The mock now accepts RequestInfo | URL.

No files excluded.

Verification

  • npm run check:tooling: 0 errors
  • npm run check: 0 errors, 0 warnings, 0 hints
  • npm run test:vitest: 64 files, 2019 tests pass
  • SKIP_PDF=1 npm run build: succeeds
  • npx knip: output identical to main
  • npx eslint on changed files: clean

🤖 Generated with Claude Code

tsconfig.astro.json only covers src/ and astro.config.mjs, so astro check
never saw script/**/*.ts, worker/*.js, e2e/, vitest.config.ts, or
playwright.config.ts. Add tsconfig.tooling.json (named so Astro and Vite
don't pick it up as a root tsconfig.json), an npm run check:tooling
script, and wire it into npm test and the CI check job.

Fix the 7 errors it surfaced (all type noise, no runtime changes):
- e2e/link-validation.spec.ts: drop unused fs/path imports
- sync-document.ts: DocumentRecord as a type alias so it satisfies
  putRecord's index-signature record param
- worker/index.test.js: JSDoc types for test helpers; ASSETS.fetch mock
  accepts RequestInfo | URL to match the binding's fetch signature

Also drop the stale _site exclude from tsconfig.astro.json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@benbalter
benbalter merged commit 1c0dd1e into main Sep 27, 2026
22 checks passed
@benbalter
benbalter deleted the audit-typecheck-tooling branch September 27, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant