prisma: Client generated by new generator fails type checking
Bug description
Using the new generator prisma-client from version 6.6.0, the generated typescript files inside the prisma client fail type checking.
Severity
⚠️ Major: Breaks core functionality (e.g., migrations fail)
Reproduction
Create any minimal prisma schema using the new client-js generator:
generator client_js {
provider = "prisma-client"
output = "generated/client"
moduleFormat = "esm"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model ExampleModel {
id String @id @default(uuid())
}
Add simple tsconfig.json:
{
"compilerOptions": {
"target": "esnext",
"lib": ["esnext", "dom", "dom.iterable"],
"module": "preserve",
"moduleResolution": "bundler",
"declaration": true,
},
"include": ["*.ts"],
"exclude": ["node_modules"],
}
Create an entry point index.ts:
import { PrismaClient } from './generated/client';
export default new PrismaClient();
Build:
❯ bunx prisma generate
Prisma schema loaded from schema.prisma
✔ Generated Prisma Client (6.6.0) to ./generated/client in 27ms
❯ bunx tsc
Expected vs. Actual Behavior
Expected to generate a .d.ts type declaration file for the entry point (index.ts)
Instead, typescript raises several type errors from inside the generated client:
generated/client/client.ts:342:16 - error TS4094: Property '_brand_DbNull' of exported anonymous class type may not be private or protected.
342 export const DbNull = runtime.objectEnumValues.instances.DbNull
~~~~~~
generated/client/client.ts:342:16
342 export const DbNull = runtime.objectEnumValues.instances.DbNull
~~~~~~
Add a type annotation to the variable DbNull.
generated/client/client.ts:349:16 - error TS4094: Property '_brand_JsonNull' of exported anonymous class type may not be private or protected.
349 export const JsonNull = runtime.objectEnumValues.instances.JsonNull
~~~~~~~~
generated/client/client.ts:349:16
349 export const JsonNull = runtime.objectEnumValues.instances.JsonNull
~~~~~~~~
Add a type annotation to the variable JsonNull.
generated/client/client.ts:356:16 - error TS4094: Property '_brand_AnyNull' of exported anonymous class type may not be private or protected.
356 export const AnyNull = runtime.objectEnumValues.instances.AnyNull
~~~~~~~
generated/client/client.ts:356:16
356 export const AnyNull = runtime.objectEnumValues.instances.AnyNull
~~~~~~~
Add a type annotation to the variable AnyNull.
Found 3 errors in the same file, starting at: generated/client/client.ts:342
Frequency
Consistently reproducible
Does this occur in development or production?
Only in development (e.g., CLI tools, migrations, Prisma Studio)
Is this a regression?
Kind of, it works with the old generator (prisma-client-js).
Workaround
Use the old generator prisma-client-js instead of the new prisma-client generator
Logs & Debug Info
❯ DEBUG="*" bunx prisma generate
prisma:config:loadConfigFromFile No config file found in the current working directory /Users/luke/Developer/misc/prisma-type-error-repro +11ms
prisma:engines binaries to download libquery-engine, schema-engine +198ms
prisma:loadEnv project root found at /Users/luke/Developer/misc/prisma-type-error-repro/package.json +272ms
prisma:getSchema prismaConfig {
"packagePath": "/Users/luke/Developer/misc/prisma-type-error-repro/package.json"
} +1ms
prisma:tryLoadEnv Environment variables not found at null +0ms
prisma:tryLoadEnv Environment variables not found at undefined +0ms
prisma:tryLoadEnv No Environment variables loaded +0ms
prisma:getSchema prismaConfig {
"packagePath": "/Users/luke/Developer/misc/prisma-type-error-repro/package.json"
} +1ms
prisma:getSchema Checking existence of /Users/luke/Developer/misc/prisma-type-error-repro/schema.prisma +0ms
prisma:getSchema Reading schema from single file /Users/luke/Developer/misc/prisma-type-error-repro/schema.prisma +0ms
Prisma schema loaded from schema.prisma
prisma:getConfig Using getConfig Wasm +1ms
prisma:getConfig config data retrieved without errors in getConfig Wasm +7ms
prisma:getDMMF Using getDmmf Wasm +59ms
prisma:getDMMF dmmf data retrieved without errors in getDmmf Wasm +13ms
prisma:client:generator requiresEngines [
"libqueryEngine"
] +1ms
prisma:mergeSchemas Using mergeSchemas Wasm +0ms
prisma:loadEnv project root found at /Users/luke/Developer/misc/prisma-type-error-repro/package.json +1ms
prisma:getSchema prismaConfig {
"packagePath": "/Users/luke/Developer/misc/prisma-type-error-repro/package.json"
} +0ms
prisma:getGenerators neededVersions {
"f676762280b54cd07c770017ed3711ddde35f37a": {
"engines": [
"libqueryEngine"
],
"binaryTargets": [
{
"fromEnvVar": null,
"value": "darwin-arm64",
"native": true
}
]
}
} +0ms
prisma:getGenerators {
"generatorBinaryPaths": {
"libqueryEngine": {
"darwin-arm64": "/Users/luke/Developer/misc/prisma-type-error-repro/node_modules/prisma/libquery_engine-darwin-arm64.dylib.node"
}
}
} +34ms
prisma:cli:bin Execution time for executing "await cli.parse(commandArray)": 222.42745900000006 ms +33ms
✔ Generated Prisma Client (6.6.0) to ./generated/client in 32ms
prisma:getSchema prismaConfig {
"packagePath": "/Users/luke/Developer/misc/prisma-type-error-repro/package.json"
} +1ms
prisma:getSchema Checking existence of /Users/luke/Developer/misc/prisma-type-error-repro/schema.prisma +0ms
prisma:getSchema Reading schema from single file /Users/luke/Developer/misc/prisma-type-error-repro/schema.prisma +0ms
prisma:getSchema prismaConfig {
"packagePath": "/Users/luke/Developer/misc/prisma-type-error-repro/package.json"
} +0ms
prisma:getSchema Checking existence of /Users/luke/Developer/misc/prisma-type-error-repro/schema.prisma +0ms
prisma:getSchema Reading schema from single file /Users/luke/Developer/misc/prisma-type-error-repro/schema.prisma +0ms
prisma:getConfig Using getConfig Wasm +0ms
prisma:getConfig config data retrieved without errors in getConfig Wasm +1ms
prisma:cli:checkpoint runCheckpointClientCheck(): Execution time for getting info: 1.3563330000000633 ms +0ms
prisma:cli:checkpoint runCheckpointClientCheck(): Execution time for "await checkpoint.check(data)": 11.649083000000019 ms +12ms
Environment & Setup
- OS: macOS 15.5 (Darwin 24.5.0 arm64 arm)
- Database: postgres but I think N/A
- Node.js version: v22.14.0
Prisma Version
prisma : 6.6.0
@prisma/client : 6.6.0
Computed binaryTarget : darwin-arm64
Operating System : darwin
Architecture : arm64
Node.js : v22.14.0
TypeScript : 5.8.3
Query Engine (Node-API) : libquery-engine f676762280b54cd07c770017ed3711ddde35f37a (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Schema Engine : schema-engine-cli f676762280b54cd07c770017ed3711ddde35f37a (at node_modules/@prisma/engines/schema-engine-darwin-arm64)
Schema Wasm : @prisma/prisma-schema-wasm 6.6.0-53.f676762280b54cd07c770017ed3711ddde35f37a
Default Engines Hash : f676762280b54cd07c770017ed3711ddde35f37a
Studio : 0.511.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 29
- Comments: 17 (1 by maintainers)
Commits related to this issue
- fix(client-generator-ts): fix null types TS errors in certain configs Depending on the TypeScript configuration, `JsonNull`/`DbNull`/`AnyNull` exports could lead to errors like: ``` Property '_brand_... — committed to prisma/prisma by aqrln 2 years ago
- fix(client-generator-ts): fix null types TS errors in certain configs (#26867) Depending on the TypeScript configuration, `JsonNull`/`DbNull`/`AnyNull` exports could lead to errors like: ``` Property... — committed to LeeeeeeM/prisma by aqrln 2 years ago
⚠️ Note: This is a temporary workaround until the Prisma team provides an official fix for this type issue. Please keep in mind that this patch modifies the generated client directly and may break with future Prisma updates.
Due to a known Prisma type issue (e.g. _brand_DbNull causing ts(4094) errors during compilation), we’ve added an automated patch after Prisma generates its client.
✅ Script Setup
We added a custom script in package.json:
🧩 What the fix does
The script scripts/fix-prisma-types.js modifies the generated client.ts file to replace broken enum exports with stable ones from NullTypes.
ts-nocheck comment fixed in https://github.com/prisma/prisma/commit/8bbb7b246314b88bc84144906f6a585a4f1223d2
I’m facing the same issue, though in my case the error is
'T' is declared but its value is never read.I used a mix of two workarounds shared above to make it work for now.maybe someone else needs it, I also encountered this problem this solution helped me add to yours eslint.config
{ ignores: [ ‘src/generated/**/*’, ] }
@aqrln This is not completed. You guys are generating TypeScript files with an erroneous
/* @ts-nocheck */comment. The correct syntax is// @ts-nocheck.So, this is wrong:
While this is correct (the TS compiler correctly skips the file):
@eannnnnn script will hold me down until fix is merged: https://github.com/prisma/prisma/pull/26867 thanks boss
Also confirming this.
Thank you for the report and the early feedback! It’s weird that this didn’t occur in our test setup, I’ll take a look.