Skip to content

Turborepo fails to compile due to type error in the generated drizzle schema #12311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
anyuj opened this issue May 3, 2025 · 0 comments · May be fixed by #12312
Open

Turborepo fails to compile due to type error in the generated drizzle schema #12311

anyuj opened this issue May 3, 2025 · 0 comments · May be fixed by #12312
Labels
status: needs-triage Possible bug which hasn't been reproduced yet

Comments

@anyuj
Copy link
Contributor

anyuj commented May 3, 2025

Describe the Bug

I have the payload generated-schema within the drizzle, which is placed with other db related files in an internal package(eg: packages/db) of my turborepo. When I tried to build the app, it says:

   Linting and checking validity of types  .Failed to compile.

../../packages/db/src/schemas/payload.ts:289:16
Type error: Invalid module name in augmentation, module '@payloadcms/db-postgres' cannot be found.

  287 | }
  288 |
> 289 | declare module '@payloadcms/db-postgres' {
      |                ^
  290 |   export interface GeneratedDatabaseSchema {
  291 |     schema: DatabaseSchema
  292 |   }
Next.js build worker exited with code: 1 and signal: null

I solved this is manually by adding a line above the generated-schema file:
import type {} from "@payloadcms/db-postgres";

This line just simply force TypeScript to load and apply the module augmentation at the bottom of the code without making pulling in any runtime code or cause other issue.

Link to the code that reproduces this issue

https://github.com/anyuj/generate-drizzle-schema-type-error

Reproduction Steps

  • create a turborepo template with pnpm dlx create-turbo@latest
  • install payload in apps/ with npx create-payload-app
  • create an internal db package, packages/db, and (please take above repo's last commit as reference)
  • pnpm generate:schema
  • then try to build the web app, you will see the error.

Which area(s) are affected? (Select all that apply)

db-postgres

Environment Info

Payload: 3.36.1
Node: 22.13.0
Next.js: 15.3.0
drizzle-orm: 0.36.1
@neondatabase/serverless: 0.10.4
@anyuj anyuj added status: needs-triage Possible bug which hasn't been reproduced yet validate-reproduction Auto-added tag on create to tell bot to check recreation URL, removed after check. labels May 3, 2025
@github-actions github-actions bot removed the validate-reproduction Auto-added tag on create to tell bot to check recreation URL, removed after check. label May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs-triage Possible bug which hasn't been reproduced yet
Projects
None yet
1 participant