fix: opt generated projects into @types globals per target (TS 6)#120
Merged
Conversation
setup-project.sh copied a single shared tsconfig with no "types" field into every generated project. TypeScript 6 removed the automatic inclusion of node_modules/@types/*, so freshly generated projects failed pnpm typecheck with TS2591/TS2584/TS2304 (process, console, setTimeout) on all five targets. - Split templates/shared/tsconfig.json into tsconfig.base.json plus per-target tsconfig.node.json (types: ["node"], also used by lambda, railway, and fly) and tsconfig.cloudflare.json (adds @cloudflare/workers-types). Generated projects get the per-target file as tsconfig.json plus the copied base. The snippet tsconfigs now extend the same per-target files, so the typecheck-templates CI job checks exactly the configuration generated projects receive. - Install @cloudflare/workers-types for the cloudflare target; the "types" entry references it and pnpm does not expose transitive packages for type resolution. - Pin typescript to its major (^6) in the generated dev dependencies so a future TS major cannot silently break generation again. - Copy tsconfig.base.json in the Docker build stage (node-server and docker templates) so pnpm build keeps working in-image. - Add a generated-projects CI matrix job that runs setup-project.sh for every target and type-checks the result against freshly resolved dependencies - the gap that let this regression ship. Fixes #119 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The script was committed mode 100644, so the documented ./scripts/setup-project.sh invocation (and the new generated-projects CI job) fails with "Permission denied" on Linux and macOS. Never noticed locally because Git Bash on Windows ignores the exec bit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Fixes #119
Problem
Every project generated by
setup-project.shfailedpnpm typecheckwith TS2591 (process), TS2584 (console), and TS2304 (setTimeout) on all five targets. The script installstypescript@latest, which now resolves to TypeScript 6 — and TS 6 removed the automatic inclusion ofnode_modules/@types/*. The copiedtemplates/shared/tsconfig.jsonhad notypesfield, so@types/nodewas installed but never loaded. CI stayed green because thetypecheck-templatesjob uses per-target snippet tsconfigs that do settypes, with a lockfile-pinned toolchain.Fix
Where the fix lives (acceptance criterion 3): per-target tsconfig templates, structured so the snippet tsconfigs extend the same files generated projects receive — drift between CI and generated output is now structurally impossible rather than comment-enforced.
templates/shared/tsconfig.json→tsconfig.base.json(content unchanged), plus two thin per-target configs:tsconfig.node.json—"types": ["node"], used by node, lambda, railway, flytsconfig.cloudflare.json—"types": ["@cloudflare/workers-types", "node"], used by cloudflareapi/tsconfig.jsonextending the copiedapi/tsconfig.base.json.templates/snippets/tsconfig.{node,lambda,cloudflare}.jsonnow extend the per-target templates and drop their owntypes— thetypecheck-templatesjob type-checks through the exact configuration that ships.@cloudflare/workers-types(referenced by itstypesentry; pnpm doesn't expose transitive packages for type resolution). The sync NOTE in the script claimed this was "added per-platform below" but it never was.typescriptis pinned to its major (^6) in the generated dev deps so the next TS major can't silently break generation; comment updated with the rationale. Snippets already pin^6.0.2.node-serveranddockerDockerfiles copytsconfig.base.jsoninto the build stage so in-imagepnpm buildkeeps working.CI gap closed
New
generated-projectsmatrix job runs the realsetup-project.shfor all five targets and type-checks the result. Deliberately no lockfile — it installs whateverpnpm addresolves that day, so a dependency release that breaks fresh projects fails in CI instead of only on user machines (exactly how this regression shipped).Verification
--nodeproject,typescript@6.0.3→ the exact TS2591/TS2584/TS2304 errors from the issue.typescript@6.0.3(pin written as^6.0.3) and passespnpm typecheck.pnpm build(tsc emit, the Docker build path) passes on the node target;dist/index.jsemitted.extendschain.projectService) resolves the extends chain; generated-project lint errors drop from 53 to 11. The remaining 11 are pre-existing stylistic findings in the snippet sources, unrelated to this issue.🤖 Generated with Claude Code