Skip to content

Make strict the only type check (TS21) - #32

Merged
Finesssee merged 5 commits into
mainfrom
ts/ts21-strict-only
Oct 11, 2026
Merged

Finesssee merged 5 commits into
mainfrom
ts/ts21-strict-only

Conversation

@Finesssee

@Finesssee Finesssee commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

TS21, the last PR of the strict TypeScript port. Strict is now the only type check: the three loose programs are gone, and every TypeScript file is in a strict program. Nothing changes at runtime: the build diff against main finds only three comment-only differences (below), and every JavaScript bundle is identical.

What changes for contributors

  • tsconfig.base.json sets strict, noUncheckedIndexedAccess and exactOptionalPropertyTypes (plus noEmit) for every program. checkJs is gone. allowJs stays only so that site.config.js, the one JavaScript file in any program, is checked through its own // @ts-check. rg "checkJs|allowJs" tsconfig*.json shows just that line.

  • bun run typecheck runs tsc on five strict programs, then port-check --strict-list:

    Config Globals Holds
    tsconfig.worker.json Workers server/**/*.ts
    tsconfig.web.json DOM, vite/client src/**/*.ts, types/dom.ts
    tsconfig.node.json Workers, Node scripts, vite.config.ts, cloudflare.config.ts, unit tests of Worker modules and their helpers
    tsconfig.node-dom.json DOM, Node unit tests of DOM modules, Playwright code, the character build
    tsconfig.node-all.json Workers, DOM, Node tests that import both a Worker module and a DOM module
  • server/ and src/ use include, so a new file there is checked as soon as it exists. The Node programs list each file.

  • server/ is now checked strictly with Workers types only. Before this PR, it was checked strictly only with Node types mixed in.

  • Retired: tsconfig.strict.json, tsconfig.strict-web.json, tsconfig.strict-tests.json, tsconfig.strict-tests-shared.json and types/browser.d.ts. They were moved to the Recycle Bin and staged with git add -u.

  • test:unit reads tests/*.test.ts. No .mjs tests were left, so the narrower glob drops none (371 unit tests on this branch).

Why five programs, not three

The plan aimed for three. I tested each merge with the repo's tsc 7.0.2, and none of them type-checks cleanly:

  • One Node program with every type (Workers, DOM, Node):
    • @cloudflare/workers-types declares declare const Buffer: any, which hides Buffer's methods in scripts/lib/png-io.ts, scripts/lib/zip-read.ts, scripts/build-characters.ts and scripts/og-image.ts.
    • scripts/live-chat-e2e.ts gets unknown from json().
    • The DOM and Workers types disagree on BufferSource and KeyUsage in server/eventsub.ts and server/backups.ts.
  • node + node-all: still leaves those four server errors, and would add DOM globals to Node scripts.
  • node-dom + node-all: fails on the Buffer scripts, on live-chat-e2e.ts and on src/served/overlay.ts under Workers types.
  • Scripts on Node + DOM only: scripts/devtools.ts and scripts/release.ts need the generic json<T>() from the Workers types.
  • The order of the types array makes no difference.

So the split follows the globals each file actually runs with.

port-check

  • STRICT_CONFIG and its three siblings become one STRICT_CONFIGS tuple of the five configs.
  • STRICT_EXCLUSIONS is gone, because every TypeScript file is now in a strict program.
  • --strict-list prints tsconfig.worker.json, tsconfig.web.json, tsconfig.node.json, tsconfig.node-dom.json and tsconfig.node-all.json cover every TypeScript file.
  • The fixtures in tests/port/port-check.test.ts use the new names, and the five-list test covers all five. bun run test:port: 101/101 pass.
  • The next-steps line in port-rename names the Node configs.

Proof it changes no runtime code

  • node scripts/port-check.ts --base origin/main: 157 build output files compared, 3 different. All three are comment edits from the shipped-comments commit (assets/_headers, assets/admin/index.html, assets/dashboard.css), and every JS bundle is identical.
  • Its other lines are expected for a PR that isn't a port:
    • source diffs in package.json, port-check and its tests;
    • types/browser.d.ts being gone;
    • the old loose worker, web and node configs gaining the strict options.
  • bun run check passes, with 371 unit tests.
  • An untyped parameter added to server/dedupe.ts failed bun run typecheck with TS7006 in tsconfig.worker.json. One added to src/scrub.ts failed with TS7006 in tsconfig.web.json. Both were reverted and never committed.

Docs and comments

  • docs/DEVELOPMENT.md and docs/CONTRACTS.md §9 describe the five programs, the new --strict-list message and the test:unit glob.
  • AGENTS.md is 8168 bytes, down from 8179. .coderabbit.yaml no longer names tsconfig.strict.json, eventsub.js or .mjs tests.
  • Comments in public/_headers (including vite.config.ts on line 8), public/dashboard.css and admin/index.html name the .ts sources. This is a separate commit, because these files ship.

Left alone, on purpose

  • src/served/upload.ts:3 (src/admin.js) and src/served/cosmetics.ts:2 (tests/channel.test.mjs). All served modules share one ?v= hash (servedVersion in scripts/lib/served.ts), so a comment edit there makes every open overlay reload once. They belong in a change that touches the overlay anyway.
  • src/parse.ts Spec as { [K in keyof T]-?: Check }. Two call sites stop compiling:
    • STATE_CONFIG would need retyping.
    • LogRow.context has no check. Adding one changes the page bundle.
  • NON_SHIPPING in scripts/port-check.ts still matches vite\.config\.js$. Fixing it changes port-check's behavior, so it needs its own change.

tsconfig.base.json now sets strict, noUncheckedIndexedAccess and exactOptionalPropertyTypes, and allowJs only for
site.config.js (checked through its own // @ts-check). The three loose programs and the four strict lists become
five strict programs split by globals: worker (server/), web (src/), node, node-dom and node-all. port-check
--strict-list keeps every TypeScript file in one of them, with no exclusions left; test:unit reads tests/*.test.ts.
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: nesszer/pixfray/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a3a48e4b-2977-421e-b78e-e1ff855b966a

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Finesssee
Finesssee merged commit b957519 into main Oct 11, 2026
3 checks passed
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