[GH-ISSUE #899] Prisma Adapter: Cannot compile type declarations #17121

Closed
opened 2026-04-15 15:04:16 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @ccssmnn on GitHub (Dec 15, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/899

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

// auth.ts
import { PrismaClient } from "@prisma/client";
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";

const prisma = new PrismaClient();

export const auth = betterAuth({ 
  database: prismaAdapter(prisma, { provider: "postgresql" }),
});
// tsconfig.json
{
  "compilerOptions": {
    "declaration": true, // 👈 this one triggers the error
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "skipLibCheck": true,
    "strict": true,
    "target": "ESNext"
  }
}

Current vs. Expected behavior

Compiling with tsc fails. Exported variable 'auth' has or is using name 'PrismaConfig' from external module "my-project/node_modules/better-auth/dist/adapters/prisma" but cannot be named.

What version of Better Auth are you using?

1.0.21

Provide environment information

Here is a Codesandbox that reproduces the error

https://codesandbox.io/p/devbox/276rrx

Which area(s) are affected? (Select all that apply)

Types

Auth config (if applicable)

import { PrismaClient } from "@prisma/client";
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";

const prisma = new PrismaClient();

export const auth = betterAuth({ 
  database: prismaAdapter(prisma, { provider: "postgresql" }),
});

Additional context

I have a monorepo with a hono server and a vite client. The hono server exports a few modules that are used in the client to take advantage of Hono RPC and reuse a few zod schemas. To make this typesafe, I want to compile the exported modules with declarations. This bug does break the compilation and i cannot ignore the error because it is specifically related to generating type declarations.

Originally created by @ccssmnn on GitHub (Dec 15, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/899 ### Is this suited for github? - [X] Yes, this is suited for github ### To Reproduce ```typescript // auth.ts import { PrismaClient } from "@prisma/client"; import { betterAuth } from "better-auth"; import { prismaAdapter } from "better-auth/adapters/prisma"; const prisma = new PrismaClient(); export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "postgresql" }), }); ``` ```json // tsconfig.json { "compilerOptions": { "declaration": true, // 👈 this one triggers the error "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "module": "ESNext", "moduleResolution": "Bundler", "skipLibCheck": true, "strict": true, "target": "ESNext" } } ``` ### Current vs. Expected behavior Compiling with tsc fails. `Exported variable 'auth' has or is using name 'PrismaConfig' from external module "my-project/node_modules/better-auth/dist/adapters/prisma" but cannot be named.` ### What version of Better Auth are you using? 1.0.21 ### Provide environment information ```bash Here is a Codesandbox that reproduces the error https://codesandbox.io/p/devbox/276rrx ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript import { PrismaClient } from "@prisma/client"; import { betterAuth } from "better-auth"; import { prismaAdapter } from "better-auth/adapters/prisma"; const prisma = new PrismaClient(); export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "postgresql" }), }); ``` ### Additional context I have a monorepo with a hono server and a vite client. The hono server exports a few modules that are used in the client to take advantage of Hono RPC and reuse a few zod schemas. To make this typesafe, I want to compile the exported modules with declarations. This bug does break the compilation and i cannot ignore the error because it is specifically related to generating type declarations.
GiteaMirror added the lockedbug labels 2026-04-15 15:04:16 -05:00
Author
Owner

@ccssmnn commented on GitHub (Dec 15, 2024):

exporting the interface PrismaConfig in the Prisma adapter fixes this issue.

<!-- gh-comment-id:2543935555 --> @ccssmnn commented on GitHub (Dec 15, 2024): exporting the interface `PrismaConfig` in the Prisma adapter fixes this issue.
Author
Owner

@ping-maxwell commented on GitHub (Dec 15, 2024):

Yeah, better auth doesn't work with declarations enabled:
https://www.better-auth.com/docs/concepts/typescript#typescript-config

<!-- gh-comment-id:2543948564 --> @ping-maxwell commented on GitHub (Dec 15, 2024): Yeah, better auth doesn't work with declarations enabled: https://www.better-auth.com/docs/concepts/typescript#typescript-config
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#17121