I'm working on a typescript project with Prisma and I saw this code on this guide that is using typescript. However my linter gives me errors for the following code.
import { PrismaClient } from '@prisma/client';
let prisma: PrismaClient;
if (process.env.NODE_ENV === 'production') {
prisma = new PrismaClient();
} else {
if (!global.prisma) {
global.prisma = new PrismaClient();
}
prisma = global.prisma;
}
export default prisma;
The error message for lines 8,9,11 (for global.prisma) is the following
Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. ts(7017)
How can I extend the type of globalThis or global with Prismaclient so that it works as intended?