-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Bug description
I have a monorepo using pnpm that matches the setup from this example:
However, types aren't exported from the peer package when being used in the consuming package - even in the official prisma example shown above. The client functions correctly and returns results, but the exported client is simply of type "any", which is a major nuisance when authoring code with the client.
I've tried importing directly from the dist
folder from within the prisma
package in the repo and the types are correct when doing intra-package imports. The issue is only when importing from a sibling package within the monorepo. I suspect that makes this a typescript issue, but I don't know how to resolve it and would love for the example project to be updated correctly.
Severity
🔹 Minor: Unexpected behavior, but does not block development
Reproduction
- Clone the prisma-examples repo
cd generator-prisma-client/nextjs-starter-webpack-monorepo
pnpm install && pnpm run build
- Open
packages/next-app/lib/utils/query.ts
inside your IDE, hover over theprisma
import and observe that it has a type of "any"
Expected vs. Actual Behavior
Expected proper types on prisma client exported from monorepo package, but getting "any" instead.
Frequency
Consistently reproducible
Does this occur in development or production?
Only in development (e.g., CLI tools, migrations, Prisma Studio)
Is this a regression?
No
Workaround
No workaround, but the client behaves as expected despite the types not being exported correctly.
Prisma Schema & Queries
import prisma from '@/lib/db'
export const getQuotes = async () => {
const start = Date.now()
// `prisma` is of type "any" so there's no completions for these methods or the response
const result = await prisma.quotes.findMany({
orderBy: {
id: 'desc',
},
take: 1,
})
return {
data: result,
}
}
export const addQuote = async (quote: string) => {
// Same here
return await prisma.quotes.create({
data: {
quote,
},
})
}
Prisma Config
// See: https://www.prisma.io/docs/orm/prisma-schema/overview/generators#field-reference-1
generator client {
provider = "prisma-client"
output = "../src/generated/prisma"
previewFeatures = ["driverAdapters", "queryCompiler"]
}
Logs & Debug Info
// Debug logs here
Environment & Setup
- OS: macOS
- Database: PostgreSQL
- Node.js version: 22.16.0
Prisma Version
6.11.1