Get type of prisma client before it is defined
In my next.js app I have to use the following approach to prevent multiple instances of PrismaClient being created
The above approach however is problematic because it doesn't generate the correct PrismaClient type. E.g. in my project TS will complain that
I tried solving this with
The above approach however is problematic because it doesn't generate the correct PrismaClient type. E.g. in my project TS will complain that
db.user.example doesn't exist.I tried solving this with
typeof new PrismaClient().$extends(extension) but I need globalForPrisma to be defined before the PrismaClient has been defined