zenstack
zenstack copied to clipboard
typescript types broken on zod schema plugin on delegated tables in zenstack v2.5.1
zenstack v2.5.1 introduces new error.
for example for this schema:
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "rhel-openssl-3.0.x"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
plugin zod {
provider = '@core/zod'
}
model Animal {
id String @id @default(uuid())
animalType String @default("")
@@delegate(animalType)
}
model Dog extends Animal {
name String
}
you get the following error:
~/development/projects/tmp/zenstack-sample-issue ············································································································································································································································ 6s 19:12:41 ─╮
❯ zenstack generate ─╯
⌛️ ZenStack CLI v2.5.1, running plugins
✔ Generating Prisma schema
✔ Generating PrismaClient enhancer
✔ Generating Zod schemas
Error compiling generated code:
node_modules/.pnpm/@[email protected]_@[email protected][email protected]_/node_modules/.zenstack/zod/models/Animal.schema.ts:41:23 - error TS2322: Type 'boolean' is not assignable to type 'never'.
41 id: true, animalType: true
~~~~~~~~~~
node_modules/.pnpm/@[email protected]_@[email protected][email protected]_/node_modules/.zenstack/zod/models/Animal.schema.ts:49:23 - error TS2322: Type 'boolean' is not assignable to type 'never'.
49 id: true, animalType: true
~~~~~~~~~~
node_modules/.pnpm/@[email protected]_@[email protected][email protected]_/node_modules/.zenstack/zod/models/Dog.schema.ts:43:23 - error TS2322: Type 'boolean' is not assignable to type 'never'.
43 id: true, animalType: true
~~~~~~~~~~
node_modules/.pnpm/@[email protected]_@[email protected][email protected]_/node_modules/.zenstack/zod/models/Dog.schema.ts:51:23 - error TS2322: Type 'boolean' is not assignable to type 'never'.
51 id: true, animalType: true
~~~~~~~~~~
: Error compiling generated code
removing zod plugin or @@delegate field would relax this issue. currently we decided not to upgrade because we are using zod schemas in our app.
Environment (please complete the following information):
- ZenStack version: 2.5.1
- Prisma version: 5.15.1
- Database type: Postgresql