Skip to content

jcubic/prisma-7-bug

Repository files navigation

Prisma 7 TypeScript Error Reproduction

Minimal reproduction case for prisma/prisma#28620

Issue

When using Prisma 7 with dual schema setup (two different databases), TypeScript throws an error during npm run build:

Type error: This expression is not callable.
  Each member of the union type '(<T extends AccountFindFirstArgs>(args?: SelectSubset<T, AccountFindFirstArgs<DefaultArgs>> | undefined) => Prisma__AccountClient<GetFindResult<$AccountPayload<DefaultArgs>, T, { ...; }> | null, null, DefaultArgs, { ...; }>) | (<T extends AccountFindFirstArgs>(args?: SelectSubset<...> | undefined) => Prisma__Account...' has signatures, but none of those signatures are compatible with each other.

This error occurs at the findFirst call in src/app/actions.ts:6:40.

Setup

This project demonstrates the issue with:

  • Next.js 16.1.6 with TypeScript
  • Prisma 7.4.0 with dual schema configuration
  • Two Prisma schemas:
    • prisma-1/ - MySQL schema
    • prisma-2/ - SQLite schema
  • Unified Prisma client in src/lib/prisma.ts that switches between clients based on environment

Project Structure

prisma-7-bug/
├── prisma-1/
│   ├── schema.prisma      # MySQL schema
│   └── types/             # Generated MySQL client
├── prisma-2/
│   ├── schema.prisma      # SQLite schema
│   └── types/             # Generated SQLite client
├── src/
│   ├── app/
│   │   ├── actions.ts     # Server action with findFirst call (ERROR HERE)
│   │   └── page.tsx       # Page that calls the action
│   └── lib/
│       └── prisma.ts      # Unified client that imports both schemas
├── prisma.config.ts       # Prisma config for dual setup
└── .env                   # Environment variables

Reproduction Steps

  1. Install dependencies:

    npm install
  2. Generate Prisma clients:

    npx prisma generate --schema ./prisma-1/schema.prisma
    npx prisma generate --schema ./prisma-2/schema.prisma
  3. Run build (reproduces the error):

    npm run build

Expected Behavior

The build should complete successfully without TypeScript errors.

Actual Behavior

TypeScript compilation fails with the error:

./src/app/actions.ts:6:40
Type error: This expression is not callable.

The error occurs at prisma.account.findFirst({...}) in the server action.

Key Files

src/lib/prisma.ts

This file creates a unified Prisma client by:

  1. Importing both PrismaClient from the two generated schemas
  2. Re-exporting types from prisma-1
  3. Conditionally creating either client based on USE_SQLITE env var

src/app/actions.ts

Contains a minimal server action that calls prisma.account.findFirst(), which triggers the TypeScript error during build.

Environment

  • Next.js: 16.1.6
  • Prisma: 7.4.0
  • TypeScript: 5.x
  • OS: Linux (Fedora)

Notes

  • The error only occurs during Next.js build, not during runtime
  • The error is specific to TypeScript type checking
  • Both schemas have identical Account model definitions
  • The issue appears to be related to type union incompatibility when combining two Prisma clients

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors