G'day. I'm using typescript script, and defining a...
# prisma-client
m
G'day. I'm using typescript script, and defining an event listener for queries as seen here: https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#log-a-query-event-to-console. However, TypeScript is complaining "TS7006: Parameter 'event' implicitly has an 'any' type.". According to the Prisma docs, a query event is a QueryEvent type, but I can't figure out how to import that type so that TypeScript knows it exists.
🚀 1
Copy code
import type { QueryEvent } from '@prisma';
or
Copy code
import type { QueryEvent } from '@prisma/client';
do not work.
And if I just go "event: any", then I get TS2345: Argument of type '"query"' is not assignable to parameter of type '"beforeExit"'.
To fix my problems, replace:
Copy code
import { PrismaClient } from '@prisma/client';
with
Copy code
import { Prisma, PrismaClient } from '@prisma/client';
and:
Copy code
interface Container {
   prisma: PrismaClient;
with
Copy code
interface Container {
   prisma: PrismaClient<Prisma.PrismaClientOptions, 'query'>;
Everything seems to work after that 😄