Type Issues with Client Extension in Nest JS
Hello, I am trying client extension with my nestjs application. But I am facing some type issues, can you help me.
here is my code.
here is my PrismaService:
I am getting this error from this.extendedclient.
2 Replies
Hi @KingMaLiTHa
Can you define the ExtendedPrismaClient type like this?
Then modify your PrismaService like:
We defined the extended client as a function that takes a PrismaClient instance and returns the extended version. Then use the ReturnType to infer the type of the extended client. In the PrismaService constructor, we call the extendedPrismaClient function with this as the argument.
You can also take a look at the is Github issue
GitHub
Ability to extend
PrismaClient
class w/ Client Extensions before ...Problem Within NestJS, the common solution to implementing an injectable Prisma Client instance is to extend PrismaClient and add the onModuleInit and enableShutdownHooks functions required by Nest...