Skip to content

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

@wh5938316

Description

@wh5938316

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglockedLocked conversations after being closed for 7 days

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions