neofrog.
PPrisma
•Created by neofrog. on 8/4/2024 in #help-and-questions
Prisma type inference is returning weird types
I'm encountering an issue with TypeScript not properly inferring the types when using PrismaClient in my Node.js typescript application.
Setup:
Prisma Schema:
Prisma Client Initialization:
When I perform a simple findUnique query, TypeScript infers the type as PrismaAccountClient<Account | null> instead of the expected model type.
Expected Type:
account should be inferred as Account | null.
Actual Type:
account is inferred as PrismaAccountClient<Account | null>.
Question:
How can I ensure that TypeScript infers the correct type (Account | null) for the result of the findUnique query without needing to manually set the types?
Any help would be greatly appreciated!
19 replies