Skip to content

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

Closed
@anyuj

Description

@anyuj

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)
  • cd apps/payload then pnpm generate:schema
  • then cd ../web try to build the web app with pnpm run build, 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions