[GH-ISSUE #3103] The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed #26797

Closed
opened 2026-04-17 17:30:07 -05:00 by GiteaMirror · 10 comments
Owner

Originally created by @sovetski on GitHub (Jun 20, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3103

When we combine admin and organization plugins, we have this error:

The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed

Image

My code:

export const auth = betterAuth({
    database: prismaAdapter(prisma, {
        provider: "mysql",
    }),
    emailAndPassword: {
        enabled: true,
    },
    plugins: [
        admin(),
        organization(),
        nextCookies(),
    ],
});

Originally created by @sovetski on GitHub (Jun 20, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3103 When we combine `admin` and `organization` plugins, we have this error: `The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed` ![Image](https://github.com/user-attachments/assets/2dfcaf36-cada-41ad-adb2-17c0f5d77967) My code: ```ts export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "mysql", }), emailAndPassword: { enabled: true, }, plugins: [ admin(), organization(), nextCookies(), ], }); ```
GiteaMirror added the locked label 2026-04-17 17:30:07 -05:00
Author
Owner

@GeorgeIpsum commented on GitHub (Jun 20, 2025):

This happens to me as well when I have "declaration" set to "true" in my tsconfig. I've been getting around this for now by exporting raw TS and having my downstream app bundlers deal with my auth library, but if there was any way to simplify the resulting type so I could precompile the auth library that would be nice

<!-- gh-comment-id:2991962550 --> @GeorgeIpsum commented on GitHub (Jun 20, 2025): This happens to me as well when I have "declaration" set to "true" in my tsconfig. I've been getting around this for now by exporting raw TS and having my downstream app bundlers deal with my auth library, but if there was any way to simplify the resulting type so I could precompile the auth library that would be nice
Author
Owner

@maulik13 commented on GitHub (Jun 23, 2025):

Yes same here. It would be nice to either suppress this warning or find a solution.

<!-- gh-comment-id:2995936282 --> @maulik13 commented on GitHub (Jun 23, 2025): Yes same here. It would be nice to either suppress this warning or find a solution.
Author
Owner

@lucasasap commented on GitHub (Jun 23, 2025):

Happening to me as well... It works fine on Next.js, but if I try to use it on Express or Hono... it doesn't work.

<!-- gh-comment-id:2997326780 --> @lucasasap commented on GitHub (Jun 23, 2025): Happening to me as well... It works fine on Next.js, but if I try to use it on Express or Hono... it doesn't work.
Author
Owner

@niklashansson commented on GitHub (Jun 25, 2025):

Same here! Using BA with Hono. For me it's the organization plugin coupled with stripe plugin that causes the infer error.

<!-- gh-comment-id:3003772074 --> @niklashansson commented on GitHub (Jun 25, 2025): Same here! Using BA with Hono. For me it's the organization plugin coupled with stripe plugin that causes the infer error.
Author
Owner

@Kinfe123 commented on GitHub (Jun 26, 2025):

@lucasasap can you please use tsconfig like below

{
  "compilerOptions": {
    "strict": true,
    "types": [
      "node"
    ],
    "jsx": "react-jsx",
    "jsxImportSource": "hono/jsx",
  }
}

<!-- gh-comment-id:3010051801 --> @Kinfe123 commented on GitHub (Jun 26, 2025): @lucasasap can you please use tsconfig like below ```json { "compilerOptions": { "strict": true, "types": [ "node" ], "jsx": "react-jsx", "jsxImportSource": "hono/jsx", } } ```
Author
Owner

@Kinfe123 commented on GitHub (Jun 26, 2025):

@niklashansson is it that the same problem that with the issue opened ? would you mind sharing your tsconfig ? and @sovetski you too as well

<!-- gh-comment-id:3010061345 --> @Kinfe123 commented on GitHub (Jun 26, 2025): @niklashansson is it that the same problem that with the issue opened ? would you mind sharing your tsconfig ? and @sovetski you too as well
Author
Owner

@niklashansson commented on GitHub (Jun 27, 2025):

@niklashansson is it that the same problem that with the issue opened ? would you mind sharing your tsconfig ? and @sovetski you too as well

Yes! Getting the "The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed." on the auth instance. Been trying to solve it for the last couple of days with no luck unfortunately

Used in a Turborepo repo, Hono app


// apps/api/tsconfig.json

{
  "extends": "@kvark/typescript-config/base.json",
  "compilerOptions": {
  	"lib": ["ESNext"],
  	"types": ["node"],
  	"allowJs": true,
  	"outDir": "./dist",
  	"rootDir": "./src",
  	"baseUrl": ".",
  	"paths": {
  		"@/*": ["src/*"]
  	}
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist"],
  "tsc-alias": {
  	"resolveFullPaths": true
   }
}

// packages/typescript-config/base.json

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "compilerOptions": {
    "declaration": true,
    "declarationMap": true,
    "esModuleInterop": true,
    "incremental": false,
    "isolatedModules": true,
    "lib": ["ESNext", "DOM", "DOM.Iterable"],
    "module": "ESNext",
    "moduleDetection": "force",
    "moduleResolution": "bundler",
    "noUncheckedIndexedAccess": true,
    "resolveJsonModule": true,
    "forceConsistentCasingInFileNames": true,
    "skipLibCheck": true,
    "strict": true,
    "target": "ESNext"
  },
  "exclude": ["node_modules"]
}


@Kinfe123 - thanks!

<!-- gh-comment-id:3013401676 --> @niklashansson commented on GitHub (Jun 27, 2025): > [@niklashansson](https://github.com/niklashansson) is it that the same problem that with the issue opened ? would you mind sharing your tsconfig ? and [@sovetski](https://github.com/sovetski) you too as well Yes! Getting the "The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed." on the auth instance. Been trying to solve it for the last couple of days with no luck unfortunately Used in a Turborepo repo, Hono app ```typescript // apps/api/tsconfig.json { "extends": "@kvark/typescript-config/base.json", "compilerOptions": { "lib": ["ESNext"], "types": ["node"], "allowJs": true, "outDir": "./dist", "rootDir": "./src", "baseUrl": ".", "paths": { "@/*": ["src/*"] } }, "include": ["src/**/*"], "exclude": ["node_modules", "dist"], "tsc-alias": { "resolveFullPaths": true } } // packages/typescript-config/base.json { "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { "declaration": true, "declarationMap": true, "esModuleInterop": true, "incremental": false, "isolatedModules": true, "lib": ["ESNext", "DOM", "DOM.Iterable"], "module": "ESNext", "moduleDetection": "force", "moduleResolution": "bundler", "noUncheckedIndexedAccess": true, "resolveJsonModule": true, "forceConsistentCasingInFileNames": true, "skipLibCheck": true, "strict": true, "target": "ESNext" }, "exclude": ["node_modules"] } ``` @Kinfe123 - thanks!
Author
Owner

@maulik13 commented on GitHub (Jul 6, 2025):

@ping-maxwell I tried this with the latest 1.2.12 and I still see this issue when adding additional fields to the user schema.

<!-- gh-comment-id:3042659011 --> @maulik13 commented on GitHub (Jul 6, 2025): @ping-maxwell I tried this with the latest 1.2.12 and I still see this issue when adding additional fields to the user schema.
Author
Owner

@maulik13 commented on GitHub (Jul 7, 2025):

I managed to fix my issue using the solution mentioned here https://github.com/better-auth/better-auth/issues/3067#issuecomment-2988246817

<!-- gh-comment-id:3043784926 --> @maulik13 commented on GitHub (Jul 7, 2025): I managed to fix my issue using the solution mentioned here https://github.com/better-auth/better-auth/issues/3067#issuecomment-2988246817
Author
Owner

@niklashansson commented on GitHub (Jul 7, 2025):

@maulik13 - I can confirm that this solved it for me as well! Thx.

<!-- gh-comment-id:3044000182 --> @niklashansson commented on GitHub (Jul 7, 2025): @maulik13 - I can confirm that this solved it for me as well! Thx.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#26797