Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NestJS Prisma client unable to import generated types

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

like image 635
Bloopie Bloops Avatar asked Oct 24 '25 02:10

Bloopie Bloops


1 Answers

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> {
  ...
}
like image 174
Hnennyi Andrii Avatar answered Oct 26 '25 16:10

Hnennyi Andrii