TypeScript Error: Type instantiation is excessively deep and possibly infinite when using plugins admin and organization #432

Closed
opened 2026-03-13 07:45:36 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @wh5938316 on GitHub (Dec 19, 2024).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Set up a NestJS project with better-auth.

  2. Set declaration: false and strict: true in tsconfig.json

  3. Enable the admin and organization plugins in the configuration:

const auth = betterAuth({
  plugins: [admin(), organization()],
});

Current vs. Expected behavior

When using better-auth in a NestJS project, enabling the admin and organization plugins causes TypeScript to throw the following error:

Type instantiation is excessively deep and possibly infinite. (ts2589)

I have already followed the instructions provided in the TypeScript configuration documentation by setting the following options in my tsconfig.json:

{
  "compilerOptions": {
    "declaration": false,
    "strict": true
  }
}

However, the issue persists. Without enabling these two plugins (admin and organization), everything works perfectly fine.

What version of Better Auth are you using?

1.0.22

Provide environment information

- Framework: NestJS
- typescript: 5.7.2

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

Types

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  plugins: [
    anonymous(),
    admin(),
    organization(),
});

Additional context

No response

Originally created by @wh5938316 on GitHub (Dec 19, 2024). ### Is this suited for github? - [X] Yes, this is suited for github ### To Reproduce 1. Set up a NestJS project with better-auth. 2. Set `declaration: false` and `strict: true` in tsconfig.json 3. Enable the admin and organization plugins in the configuration: ``` const auth = betterAuth({ plugins: [admin(), organization()], }); ``` ### Current vs. Expected behavior When using better-auth in a NestJS project, enabling the admin and organization plugins causes TypeScript to throw the following error: ``` Type instantiation is excessively deep and possibly infinite. (ts2589) ``` I have already followed the instructions provided in [the TypeScript configuration documentation](https://www.better-auth.com/docs/concepts/typescript) by setting the following options in my tsconfig.json: ``` json { "compilerOptions": { "declaration": false, "strict": true } } ``` However, the issue persists. Without enabling these two plugins (admin and organization), everything works perfectly fine. ### What version of Better Auth are you using? 1.0.22 ### Provide environment information ```bash - Framework: NestJS - typescript: 5.7.2 ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ plugins: [ anonymous(), admin(), organization(), }); ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 07:45:36 -05:00
Author
Owner

@Bekacru commented on GitHub (Dec 20, 2024):

Hey could you try 1.0.23-beta.5 and see if it fixes the issue for you?

@Bekacru commented on GitHub (Dec 20, 2024): Hey could you try `1.0.23-beta.5` and see if it fixes the issue for you?
Author
Owner

@wh5938316 commented on GitHub (Dec 20, 2024):

Hey could you try 1.0.23-beta.5 and see if it fixes the issue for you?

I tried it, and the issue has been fixed in version 1.0.23-beta.5

@wh5938316 commented on GitHub (Dec 20, 2024): > Hey could you try `1.0.23-beta.5` and see if it fixes the issue for you? I tried it, and the issue has been fixed in version `1.0.23-beta.5`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#432