Skip to content

fix(dev): make the demo app type-check and build - #69

Merged
bvdaakster merged 1 commit into
mainfrom
fix/dev-app-typecheck
Nov 28, 2026
Merged

bvdaakster merged 1 commit into
mainfrom
fix/dev-app-typecheck

Conversation

@bvdaakster

Copy link
Copy Markdown
Contributor

next build dev and tsc -p dev/tsconfig.json both failed. Nothing under src/ changes; the emitted .d.ts files are byte-identical before and after the TypeScript update.

What was wrong, and the fix

  • dev/payload-types.ts ended in a declare module 'payload' block. It narrowed Payload's collection slugs for the whole program, including the plugin source the demo app compiles, which is written against any config (errors in src/hooks/server.ts and src/endpoints/publicFlags.ts). The dev config now sets typescript.declare: false, and autoGenerate: false.
  • dev/int.spec.ts relied on that augmentation for one assignment. It now casts the result to the generated document type and assigns that to FeatureFlagDocument, so the compile-time check stays. dev/cache.spec.ts wrapped a generic function in vi.fn(), which drops the type parameter.
  • Next 16 generates .next/types/validator.ts as a CommonJS file that does typeof import() of the ESM routes. TypeScript 5.7 rejects that under NodeNext (TS1542); 5.8+ accepts it. TypeScript goes from 5.7.3 to 5.9.3 (devDependency).
  • The admin import map imports @xtr-dev/payload-feature-flags/views, which resolved through exports to dist/, so the demo app only compiled after pnpm build. dev/tsconfig.json now maps the package name to src.
  • The demo home page was prerendered, so next build queried a database with no tables. It is now force-dynamic, which also fits a page that shows current flag state.

CI

New pnpm dev:build script and CI step, so the demo app's compile and type check run on every PR.

Checked locally

pnpm lint (0 errors), tsc --noEmit, tsc -p dev/tsconfig.json, pnpm test (95 passed, no type errors), pnpm build, pnpm dev:build from a checkout without dist/, and next dev: /admin, / and the public evaluate endpoint answer 200.

Not covered: the Playwright e2e suite still does not run in CI.

🤖 Generated with Claude Code

https://claude.ai/code/session_0122PV8TJ7ELGdAX7H2hdrRU

- dev/payload.config.ts: typescript.declare false, so the generated types
  no longer narrow Payload's collection slugs for the plugin source that
  the demo app compiles; autoGenerate false.
- dev/tsconfig.json: map @xtr-dev/payload-feature-flags/* to src, so the
  admin import map resolves without a built dist/.
- typescript 5.7.3 -> 5.9.3 (dev): Next's generated route validator is a
  CommonJS file importing the ESM routes, which 5.7 rejects under NodeNext.
- Demo home page is rendered per request; prerendering it queried a
  database without tables during next build.
- Two spec files typed correctly without the module augmentation.
- New dev:build script, run in CI.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0122PV8TJ7ELGdAX7H2hdrRU
@claude

claude Bot commented Nov 28, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@bvdaakster
bvdaakster merged commit 2958f6e into main Nov 28, 2026
6 checks passed
@bvdaakster
bvdaakster deleted the fix/dev-app-typecheck branch November 28, 2026 14:53
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