Closed nahtnam closed 5 months ago
Hi @nahtnam , thanks for filing this.
I checked the code and it seems next-admin has a hard-coded dependency to @prisma/client
and doesn't allow customize its typing. Have you tried casting the enhanced prismaclient back to PrismaClient
type and see if it works?
When using auth()
in @default()
, the only difference between zenstack-enhanced client and the original client's typing is the optionality of that field. It probably won't makes a real difference I suppose.
Awesome, that seemed to do the trick! Do you know if there will ever be a case in the future where the change is not so type safe? Where type casting might cause issues?
In this case it's totally fine like you said because the types that the next-admin
library uses is stricter
Description and expected behavior
https://github.com/nahtnam/zenstack-default-auth-bug
To reproduce, clone this repo and run:
To prove this is related to
@default
, you can remove it from this line: https://github.com/nahtnam/zenstack-default-auth-bug/blob/main/schema.zmodel#L38Then regenerate zenstack and check the types
Also to prove that this is not a bug with the repo, you can change this line to directly use the prisma client and typescript will not complain: https://github.com/nahtnam/zenstack-default-auth-bug/blob/main/src/app/admin/%5B%5B...nextadmin%5D%5D/page.tsx#L20
Screenshots
Environment (please complete the following information):
Additional context N/A