NestJS - Type instantiation is excessively deep and possibly infinite #388

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

Originally created by @arashi-dev on GitHub (Dec 12, 2024).

Describe the bug
The object's type returned from betterAuth() is too slow and takes about 10 seconds to iterate the types in NestJS. if I use any properties of the auth.api property, it gives me the error: Type instantiation is excessively deep and possibly infinite

To Reproduce
Steps to reproduce the behavior:

  1. build a nest project using npx @nestjs/cli new my-project
  2. make a new .ts file somewhere in the /src directory
  3. import the betterAuth and run simply call it.

Expected behavior
The type-intellisense must be much much much faster than this.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • Node Version: 20.11.0
  • Package Manager: Yarn
  • Typescript Version (as from the official starter template, v5.1.3)

Additional context

tsconfig.json
{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "ES2021",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "skipLibCheck": true,
    "strictNullChecks": false,
    "noImplicitAny": false,
    "strictBindCallApply": false,
    "forceConsistentCasingInFileNames": false,
    "noFallthroughCasesInSwitch": false
  }
}
Originally created by @arashi-dev on GitHub (Dec 12, 2024). **Describe the bug** The object's type returned from `betterAuth()` is too slow and takes about 10 seconds to iterate the types in NestJS. if I use any properties of the `auth.api` property, it gives me the error: `Type instantiation is excessively deep and possibly infinite` **To Reproduce** Steps to reproduce the behavior: 1. build a nest project using `npx @nestjs/cli new my-project` 2. make a new `.ts` file somewhere in the `/src` directory 3. import the `betterAuth` and run simply call it. **Expected behavior** The type-intellisense must be much much much faster than this. **Screenshots** If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - OS: Windows 10 - Node Version: 20.11.0 - Package Manager: Yarn - Typescript Version (as from the official starter template, v5.1.3) **Additional context** ###### tsconfig.json ```json { "compilerOptions": { "module": "commonjs", "declaration": true, "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowSyntheticDefaultImports": true, "target": "ES2021", "sourceMap": true, "outDir": "./dist", "baseUrl": "./", "incremental": true, "skipLibCheck": true, "strictNullChecks": false, "noImplicitAny": false, "strictBindCallApply": false, "forceConsistentCasingInFileNames": false, "noFallthroughCasesInSwitch": false } } ```
Author
Owner

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

set declaration:false and strict:true

https://www.better-auth.com/docs/concepts/typescript

@Bekacru commented on GitHub (Dec 12, 2024): set `declaration:false` and `strict:true` https://www.better-auth.com/docs/concepts/typescript
Author
Owner

@arashi-dev commented on GitHub (Dec 12, 2024):

@Bekacru Thanks. it worked

@arashi-dev commented on GitHub (Dec 12, 2024): @Bekacru Thanks. it worked
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#388