Skip to content

Commit 88f24f8

Browse files
PAMulliganclaude
andauthored
fix: opt generated projects into @types globals per target (TS 6) (#120)
* fix: opt generated projects into @types globals per target (TS 6) 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> * fix: make setup-project.sh executable 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> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent ab3b3c5 commit 88f24f8

10 files changed

Lines changed: 69 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,35 @@ jobs:
230230
run: pnpm exec tsc --noEmit -p tsconfig.lambda.json
231231
working-directory: templates/snippets
232232

233+
# Generates a real project per target with setup-project.sh and type-checks
234+
# it. Unlike typecheck-templates this has no lockfile on purpose: it installs
235+
# whatever `pnpm add` resolves today, so a dependency release that breaks
236+
# freshly generated projects (e.g. the TypeScript 6 @types auto-include
237+
# removal, #119) fails here instead of only on user machines.
238+
generated-projects:
239+
name: Generate & Type-check (${{ matrix.platform }})
240+
runs-on: ubuntu-latest
241+
timeout-minutes: 10
242+
strategy:
243+
fail-fast: false
244+
matrix:
245+
platform: [cloudflare, node, lambda, railway, fly]
246+
steps:
247+
- uses: actions/checkout@v6
248+
249+
- uses: actions/setup-node@v6
250+
with:
251+
node-version: 22
252+
253+
- run: corepack enable
254+
255+
- name: Generate project
256+
run: ./scripts/setup-project.sh demo-${{ matrix.platform }} --${{ matrix.platform }}
257+
258+
- name: Type-check generated project
259+
run: pnpm typecheck
260+
working-directory: demo-${{ matrix.platform }}/api
261+
233262
check-links:
234263
name: Check Markdown Links
235264
runs-on: ubuntu-latest

scripts/setup-project.sh

100644100755
Lines changed: 18 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ COPY package.json pnpm-lock.yaml ./
1313
RUN pnpm install --frozen-lockfile
1414

1515
# Copy source code
16-
COPY tsconfig.json drizzle.config.ts ./
16+
COPY tsconfig.json tsconfig.base.json drizzle.config.ts ./
1717
COPY src/ ./src/
1818

1919
# Build the application

templates/node-server/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ COPY package.json pnpm-lock.yaml ./
1313
RUN pnpm install --frozen-lockfile
1414

1515
# Copy source code
16-
COPY tsconfig.json drizzle.config.ts ./
16+
COPY tsconfig.json tsconfig.base.json drizzle.config.ts ./
1717
COPY src/ ./src/
1818

1919
# Build the application
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"types": [
5+
"@cloudflare/workers-types",
6+
"node"
7+
]
8+
}
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"types": [
5+
"node"
6+
]
7+
}
8+
}

templates/snippets/tsconfig.cloudflare.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
2-
"extends": "../shared/tsconfig.json",
2+
"extends": "../shared/tsconfig.cloudflare.json",
33
"compilerOptions": {
44
"noEmit": true,
55
"moduleResolution": "bundler",
6-
"types": ["@cloudflare/workers-types", "node"],
76
"rootDir": ".",
87
"rootDirs": ["shared/src", "cloudflare/src"],
98
"paths": {}

templates/snippets/tsconfig.lambda.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
2-
"extends": "../shared/tsconfig.json",
2+
"extends": "../shared/tsconfig.node.json",
33
"compilerOptions": {
44
"noEmit": true,
55
"moduleResolution": "bundler",
6-
"types": ["node"],
76
"rootDir": ".",
87
"rootDirs": ["shared/src", "aws-lambda/src"],
98
"paths": {}

templates/snippets/tsconfig.node.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
2-
"extends": "../shared/tsconfig.json",
2+
"extends": "../shared/tsconfig.node.json",
33
"compilerOptions": {
44
"noEmit": true,
55
"moduleResolution": "bundler",
6-
"types": ["node"],
76
"rootDir": ".",
87
"rootDirs": ["shared/src", "node/src"],
98
"paths": {}

0 commit comments

Comments
 (0)