Skip to content

Types not exposed properly in monorepo with prisma-client provider #27600

@davidthor

Description

@davidthor

Bug description

I have a monorepo using pnpm that matches the setup from this example:

https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/nextjs-starter-webpack-monorepo

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

  1. Clone the prisma-examples repo
  2. cd generator-prisma-client/nextjs-starter-webpack-monorepo
  3. pnpm install && pnpm run build
  4. Open packages/next-app/lib/utils/query.ts inside your IDE, hover over the prisma 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

Metadata

Metadata

Assignees

Labels

bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.topic: generator-ts

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions