I am using Prisma with NestJs and after defining my model and running npx prisma generate, I can infer from the types when I import the generated type:
import { FulfilmentReport, FulfilmentReportCreateInput } from "@prisma/client";
Type of FulfilmentReportCreateInput (When hovered):
type FulfilmentReportCreateInput = {
experimentId: string;
variantId: string;
fileName: string;
reportType: string;
startDate: string | Date;
endDate: string | Date;
}
My schema.prisma:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model FulfilmentReport {
jobId Int @id @default(autoincrement())
experimentId String
variantId String
fileName String
reportType String
startDate DateTime
endDate DateTime
}
However the issue now is that I have an error prompting that FulfilmentReportCreateInput is not an exported member when I can see it's type?
src/fulfilment-report/fulfilment-report.service.ts:2:28 - error TS2305: Module '"@prisma/client"' has no exported member 'FulfilmentReportCreateInput'.
import { FulfilmentReport, FulfilmentReportCreateInput } from "@prisma/client";
Is this a typescript issue that it is unable to find the generated class? Have been stuck on this for some time now and could use some help
From Prisma documentation:
You can import the Prisma namespace and use dot notation to access types and utilities
So instead of
import {
FulfilmentReport,
FulfilmentReportCreateInput,
} from "@prisma/client"
write
import {
FulfilmentReport,
Prisma,
} from "@prisma/client"
and then use Prisma.FulfilmentReportCreateInput
async createFulfilmentReport(data: Prisma.FulfilmentReportCreateInput): Promise<FulfilmentReport> {
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With