TypeScript setup
August 7, 2026 ยท View on GitHub
This repo uses TypeScript project references (build mode) so the editor and CLI typechecking agree without forcing every file into a single TS "environment".
The environments
We have four distinct TypeScript environments, each with its own tsconfig. The
include lists below are representative; the configs themselves are the source
of truth.
Client
- Config:
packages/worker/tsconfig-client.json - Files:
packages/worker/client/**andpackages/worker/universal/** - Environment: browser (
DOM,DOM.Iterable) + JSX (remix/ui)
Put any module the browser bundle imports under packages/worker/universal/
(#universal/*). Do not append individual worker files to the client include
list.
Tools
- Config:
tsconfig-tools.json - Files:
playwright.config.ts,wrangler-env.ts,cli.ts,tools/**,packages/shared/src/**, MCP E2E tests, and a few test-support modules (see the config'sincludelist) - Environment: Node 26 (scripts, configs, tests)
Worker
- Config:
packages/worker/tsconfig-worker.json, withpackages/worker/tsconfig-worker-typecheck.jsonas the config actually used by CLI typechecking and the root solution file (it extendstsconfig-workerand remaps#client/app-root.tsxto an SSR stub).packages/worker/tsconfig.jsonis a thinextendswrapper for the editor. - Files:
packages/worker/src/**/*.tspackages/worker/universal/**packages/worker/env.d.ts,packages/worker/src/env-schema.ts- generated
packages/worker/worker-configuration.d.ts(vianpm run generate-types)
- Environment: Cloudflare Workers (
WebWorker,WebWorker.Iterable)
Backup control plane
- Config:
packages/backup-control-plane/tsconfig.json - Files:
packages/backup-control-plane/src/** - Environment: Cloudflare Workers (standalone backup Worker)
Solution config (project references)
The root tsconfig.json is the solution file:
- It has no
include. - It references
tsconfig-tools.json,packages/worker/tsconfig-client.json, andpackages/worker/tsconfig-worker-typecheck.json.
npm run typecheck runs:
nx run worker:typecheckโ which runstsc -b packages/worker/tsconfig-client.json packages/worker/tsconfig-worker-typecheck.json --noEmit- then
tsc --noEmit -p packages/backup-control-plane/tsconfig.json
The root solution file (and therefore tsconfig-tools.json) is used by the
editor, not by npm run typecheck.
Generated worker types (packages/worker/worker-configuration.d.ts)
packages/worker/worker-configuration.d.ts is generated and must never be
edited by hand.
- To update it, run
npm run generate-types. - This file is allowed to include relative
./src/...imports since it is generated by Wrangler. - If you see this file change in a PR, it should be explainable by changes to
Worker bindings/config (for example
packages/worker/wrangler.jsonc) or by re-running the generation script.
Common gotchas
- Missing editor types usually means the file isn't included by any of the
environment configs. Add it to the appropriate
tsconfig.*.json. - Client/worker shared code belongs in
packages/worker/universal/, not in a one-offtsconfig-client.jsonincludeentry. See import boundaries. - Worker types depend on the generated
packages/worker/worker-configuration.d.ts; runnpm run generate-typesif bindings/types drift.