From 98283ca18c1e68c44249ee7c64367b61d98d49db Mon Sep 17 00:00:00 2001 From: Anyu Jiang <189434904+anyuj@users.noreply.github.com> Date: Wed, 14 May 2025 02:23:27 +0800 Subject: [PATCH] fix(db-postgres): ensure module augmentation for generated schema is picked up correctly in turborepo (#12312) ### What? Turborepo fails to compile due to type error in the generated drizzle schema. ### Why? TypeScript may not include the module augmentation for @payloadcms/db-postgres, especially in monorepo or isolated module builds. This causes type errors during the compilation process of turborepo project. Adding the type-only import guarantees that TypeScript loads the relevant type definitions and augmentations, resolving these errors. ### How? This PR adds a type-only import statement to ensure TypeScript recognizes the module augmentation for @payloadcms/db-postgres in the generated drizzle schema from payload, and there is no runtime effect. Fixes #12311 --> ![image](https://github.com/user-attachments/assets/cdec275c-c062-4eb7-9e6a-c3bc3871dd65) --- packages/drizzle/src/utilities/createSchemaGenerator.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/drizzle/src/utilities/createSchemaGenerator.ts b/packages/drizzle/src/utilities/createSchemaGenerator.ts index 25bf2f5da..b979460b2 100644 --- a/packages/drizzle/src/utilities/createSchemaGenerator.ts +++ b/packages/drizzle/src/utilities/createSchemaGenerator.ts @@ -267,8 +267,11 @@ declare module '${this.packageName}' { */ ` + const importTypes = `import type {} from '${this.packageName}'` + let code = [ warning, + importTypes, ...importDeclarationsSanitized, schemaDeclaration, ...enumDeclarations,