TypeScript error: Property 'accessRequest' does not exist on type' 'PrismaClient' even though model exists

12 hours ago 1
ARTICLE AD BOX

I'm working on a Next.js 14 project with Prisma and getting a TypeScript error when trying to use my accessRequest model

import { NextResponse } from "next/server"; import { prisma } from "@/lib/prisma"; export async function POST(req: Request, { params }: { params: { id: string } }) { try { const { id } = params; const body = await req.json(); const notes = body?.notes || null; // Error on this line: Property 'accessRequest' does not exist on type 'PrismaClient<PrismaClientOptions>' await prisma.accessRequest.update({ where: { id }, data: { status: "REJECTED", reviewedAt: new Date(), reviewNotes: notes }, }); return NextResponse.json({ success: true }); } catch (err: any) { console.error(err); return NextResponse.json({ success: false, error: err.message }, { status: 500 }); } } /////////// What I've confirmed: The model exists in my schema (model AccessRequest { ... }) I've run npx prisma generate successfully When I log Object.keys(prisma) at runtime, accessRequest IS in the list: text Prisma models: ['organization', 'user', 'githubRepository', 'solution', 'deployment', 'accessRequest', 'auditLog', ...] The Prisma client works at runtime - I can query the database using raw SQL via prisma.$executeRaw I've tried: Restarting TypeScript server in VSCode Deleting .next folder and node_modules/.cache Regenerating Prisma client with --force Using different import methods Adding type declarations My setup: Next.js 14 Prisma 6.19.1 TypeScript 5.x VSCode on Windows lib/prisma.ts: typescript import { PrismaClient } from "@prisma/client"; const globalForPrisma = globalThis as unknown as { prisma?: PrismaClient; }; export const prisma = globalForPrisma.prisma ?? new PrismaClient(); if (process.env.NODE_ENV !== "production") { globalForPrisma.prisma = prisma; } tsconfig.json: json { "compilerOptions": { "target": "ES2017", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, "strict": true, "noEmit": true, "esModuleInterop": true, "module": "esnext", "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", "types": ["react", "react-dom", "node", "@prisma/client"], "incremental": true, "plugins": [{ "name": "next" }], "paths": { "@/*": ["./src/*"] } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "exclude": ["node_modules"] } Prisma Schema (relevant parts): prisma model AccessRequest { id String @id @default(cuid()) userId String organizationId String? status AccessRequestStatus @default(SUBMITTED) // ... other fields user User @relation(fields: [userId], references: [id]) organization Organization? @relation(fields: [organizationId], references: [id]) // ... } The error persists even though: Runtime shows the model exists IntelliSense shows prisma. but accessRequest is not in the suggestions Other models like user and organization work fine What could be causing TypeScript to not recognize this specific model? How can I fix it?
Read Entire Article