[GH-ISSUE #2018] TS error on authClient since 1.2.5 release #9008

Closed
opened 2026-04-13 04:16:02 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @LilaRest on GitHub (Mar 27, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2018

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Update Better Auth to 1.2.5
  2. Run typecheck

Current vs. Expected behavior

After upgrading to 1.2.5, the authClient definition raises this TS error:

The inferred type of 'authClient' cannot be named without a reference to '../../node_modules/better-auth/dist/shared/better-auth.BAfIsot3'. This is likely not portable. A type annotation is necessary.ts(2742)

Reverting to 1.2.4 solves the issue.
Let me know that's a deeper issue and you need more details about my specific setup

What version of Better Auth are you using?

1.2.5

Provide environment information

- OS: MacOS Sonoma
- Monorepo powered by Turborepo

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

Types

Auth config (if applicable)


Additional context

No response

Originally created by @LilaRest on GitHub (Mar 27, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2018 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Update Better Auth to 1.2.5 2. Run typecheck ### Current vs. Expected behavior After upgrading to 1.2.5, the `authClient` definition raises this TS error: ``` The inferred type of 'authClient' cannot be named without a reference to '../../node_modules/better-auth/dist/shared/better-auth.BAfIsot3'. This is likely not portable. A type annotation is necessary.ts(2742) ``` Reverting to 1.2.4 solves the issue. Let me know that's a deeper issue and you need more details about my specific setup ### What version of Better Auth are you using? 1.2.5 ### Provide environment information ```bash - OS: MacOS Sonoma - Monorepo powered by Turborepo ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-13 04:16:03 -05:00
Author
Owner

@TheKeveloper commented on GitHub (Mar 27, 2025):

This looks similar to https://github.com/better-auth/better-auth/issues/1861

One temporary fix is to disable declaration and declarationMap in your tsconfig.json, assuming that the client package isn't being used as a project reference anywhere

<!-- gh-comment-id:2757761102 --> @TheKeveloper commented on GitHub (Mar 27, 2025): This looks similar to https://github.com/better-auth/better-auth/issues/1861 One temporary fix is to disable declaration and declarationMap in your `tsconfig.json`, assuming that the client package isn't being used as a project reference anywhere
Author
Owner

@Bekacru commented on GitHub (Mar 27, 2025):

@LilaRest could you share me your authClient config and your tsconfig?

<!-- gh-comment-id:2758052386 --> @Bekacru commented on GitHub (Mar 27, 2025): @LilaRest could you share me your authClient config and your tsconfig?
Author
Owner

@LilaRest commented on GitHub (Mar 27, 2025):

@Bekacru Sure, here you go:

auth/client.ts

import { magicLinkClient } from "better-auth/client/plugins";
import { adminClient } from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";

export const authClient = createAuthClient({
  plugins: [magicLinkClient(), adminClient()],
});

export type Session = typeof authClient.$Infer.Session;

tsconfig.json

{
  "extends": "@repo/tsconfig/base.json",
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@repo/*": ["../../packages/*"]
    }
  },
  "include": ["**/*.ts", "**/*.tsx"],
  "exclude": ["node_modules"]
}

tsconfig/base.json

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "display": "Common TS Config",
  "compilerOptions": {
    "declaration": true,
    "declarationMap": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "incremental": false,
    "isolatedModules": true,
    "lib": ["es2022", "DOM", "DOM.Iterable"],
    "module": "ESNext",
    "moduleDetection": "force",
    "moduleResolution": "Bundler",
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "strict": true,
    "target": "ES2022",
    "strictNullChecks": true,
    "allowJs": true,
    "jsx": "preserve",
    "noEmit": true,
    "plugins": [{ "name": "next" }]
  },
  "exclude": ["node_modules"]
}
<!-- gh-comment-id:2758108299 --> @LilaRest commented on GitHub (Mar 27, 2025): @Bekacru Sure, here you go: `auth/client.ts` ```ts import { magicLinkClient } from "better-auth/client/plugins"; import { adminClient } from "better-auth/client/plugins"; import { createAuthClient } from "better-auth/react"; export const authClient = createAuthClient({ plugins: [magicLinkClient(), adminClient()], }); export type Session = typeof authClient.$Infer.Session; ``` `tsconfig.json` ```json { "extends": "@repo/tsconfig/base.json", "compilerOptions": { "baseUrl": ".", "paths": { "@repo/*": ["../../packages/*"] } }, "include": ["**/*.ts", "**/*.tsx"], "exclude": ["node_modules"] } ``` `tsconfig/base.json` ```json { "$schema": "https://json.schemastore.org/tsconfig", "display": "Common TS Config", "compilerOptions": { "declaration": true, "declarationMap": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "incremental": false, "isolatedModules": true, "lib": ["es2022", "DOM", "DOM.Iterable"], "module": "ESNext", "moduleDetection": "force", "moduleResolution": "Bundler", "resolveJsonModule": true, "skipLibCheck": true, "strict": true, "target": "ES2022", "strictNullChecks": true, "allowJs": true, "jsx": "preserve", "noEmit": true, "plugins": [{ "name": "next" }] }, "exclude": ["node_modules"] } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9008