[GH-ISSUE #4279] stripe plugin gives TypeScript error #27208

Closed
opened 2026-04-17 18:05:18 -05:00 by GiteaMirror · 7 comments
Owner

Originally created by @yvbbrjdr on GitHub (Aug 28, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/4279

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Add stripe plugin to the plugins array in betterAuth constructor.

Current vs. Expected behavior

TypeScript gives the following error:

Type '{ id: "stripe"; endpoints: { stripeWebhook: { <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0?: ({ body?: undefined; } & { method?: "POST" | undefined; } & { query?: Record<string, any> | undefined; } & ... 4 more ... & { ...; }) | undefined): Promise<...>; options: { ...; } & ...' is not assignable to type 'BetterAuthPlugin'.
  Types of property 'init' are incompatible.
    Type '(ctx: AuthContext) => { options: { databaseHooks: { user: { create: { after(user: { id: string; email: string; emailVerified: boolean; name: string; createdAt: Date; updatedAt: Date; image?: string | ... 1 more ... | undefined; } & Record<...>, ctx: GenericEndpointContext | undefined): Promise<...>; }; }; }; }; }' is not assignable to type '(ctx: AuthContext) => void | { context?: { password?: { hash?: ((password: string) => Promise<string>) | undefined; verify?: ((data: { password: string; hash: string; }) => Promise<...>) | undefined; config?: { ...; } | undefined; checkPassword?: ((userId: string, c: GenericEndpointContext) => Promise<...>) | undefi...'.
      Types of parameters 'ctx' and 'ctx' are incompatible.
        Type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.jwa4Tx7v", { with: { "resolution-mode": "import" } }).p' is not assignable to type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.BZajccRg").p'.
          The types of 'options.socialProviders' are incompatible between these types.
            Type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.DnUZno9_", { with: { "resolution-mode": "import" } }).S | undefined' is not assignable to type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.CkqBZvXM").S | undefined'.
              Type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.DnUZno9_", { with: { "resolution-mode": "import" } }).S' is not assignable to type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.CkqBZvXM").S'.
                Types of property 'vk' are incompatible.
                  Type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.BDR52Rf2", { with: { "resolution-mode": "import" } }).a<import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.DnUZno9_", { with: { "resolution-mode": "import" } }).ad & { enable...' is not assignable to type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.BDR52Rf2").a<import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.CkqBZvXM").ad & { enabled?: boolean | undefined; }> | undefined'.
                    Type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.BDR52Rf2", { with: { "resolution-mode": "import" } }).a<import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.DnUZno9_", { with: { "resolution-mode": "import" } }).ad & { enable...' is not assignable to type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.BDR52Rf2").a<import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.CkqBZvXM").ad & { enabled?: boolean | undefined; }>'.
                      Types of property 'lang_id' are incompatible.
                        Type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.DnUZno9_", { with: { "resolution-mode": "import" } }).ac | undefined' is not assignable to type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.CkqBZvXM").ac | undefined'.
                          Type 'LANG.RUS' is not assignable to type 'LANG | undefined'.ts(2322)

What version of Better Auth are you using?

1.3.7

System info

System:
    OS: macOS 26.0
    CPU: (8) arm64 Apple M1 Pro
    Memory: 95.00 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh

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

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
  plugins: [
    stripe({
      stripeClient,
      stripeWebhookSecret,
      createCustomerOnSignUp: true,
    }),
  ],
});

Additional context

No response

Originally created by @yvbbrjdr on GitHub (Aug 28, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/4279 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Add `stripe` plugin to the `plugins` array in `betterAuth` constructor. ### Current vs. Expected behavior TypeScript gives the following error: ``` Type '{ id: "stripe"; endpoints: { stripeWebhook: { <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0?: ({ body?: undefined; } & { method?: "POST" | undefined; } & { query?: Record<string, any> | undefined; } & ... 4 more ... & { ...; }) | undefined): Promise<...>; options: { ...; } & ...' is not assignable to type 'BetterAuthPlugin'. Types of property 'init' are incompatible. Type '(ctx: AuthContext) => { options: { databaseHooks: { user: { create: { after(user: { id: string; email: string; emailVerified: boolean; name: string; createdAt: Date; updatedAt: Date; image?: string | ... 1 more ... | undefined; } & Record<...>, ctx: GenericEndpointContext | undefined): Promise<...>; }; }; }; }; }' is not assignable to type '(ctx: AuthContext) => void | { context?: { password?: { hash?: ((password: string) => Promise<string>) | undefined; verify?: ((data: { password: string; hash: string; }) => Promise<...>) | undefined; config?: { ...; } | undefined; checkPassword?: ((userId: string, c: GenericEndpointContext) => Promise<...>) | undefi...'. Types of parameters 'ctx' and 'ctx' are incompatible. Type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.jwa4Tx7v", { with: { "resolution-mode": "import" } }).p' is not assignable to type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.BZajccRg").p'. The types of 'options.socialProviders' are incompatible between these types. Type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.DnUZno9_", { with: { "resolution-mode": "import" } }).S | undefined' is not assignable to type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.CkqBZvXM").S | undefined'. Type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.DnUZno9_", { with: { "resolution-mode": "import" } }).S' is not assignable to type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.CkqBZvXM").S'. Types of property 'vk' are incompatible. Type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.BDR52Rf2", { with: { "resolution-mode": "import" } }).a<import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.DnUZno9_", { with: { "resolution-mode": "import" } }).ad & { enable...' is not assignable to type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.BDR52Rf2").a<import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.CkqBZvXM").ad & { enabled?: boolean | undefined; }> | undefined'. Type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.BDR52Rf2", { with: { "resolution-mode": "import" } }).a<import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.DnUZno9_", { with: { "resolution-mode": "import" } }).ad & { enable...' is not assignable to type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.BDR52Rf2").a<import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.CkqBZvXM").ad & { enabled?: boolean | undefined; }>'. Types of property 'lang_id' are incompatible. Type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.DnUZno9_", { with: { "resolution-mode": "import" } }).ac | undefined' is not assignable to type 'import("/Users/yvbbrjdr/Documents/lmrouter/core/node_modules/better-auth/dist/shared/better-auth.CkqBZvXM").ac | undefined'. Type 'LANG.RUS' is not assignable to type 'LANG | undefined'.ts(2322) ``` ### What version of Better Auth are you using? 1.3.7 ### System info ```bash System: OS: macOS 26.0 CPU: (8) arm64 Apple M1 Pro Memory: 95.00 MB / 16.00 GB Shell: 5.9 - /bin/zsh ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, plugins: [ stripe({ stripeClient, stripeWebhookSecret, createCustomerOnSignUp: true, }), ], }); ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-17 18:05:18 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 28, 2025):

This TypeScript error is caused by a deep type incompatibility between the stripe plugin and the BetterAuthPlugin interface, especially in the init property and related types. This is a known issue when using certain plugins or after upgrading to newer Better Auth versions with stricter typing. The root cause is often mismatched or duplicated type definitions across the codebase and plugins, sometimes exacerbated by differences in how types are imported or resolved by TypeScript1 2 .

You have a few options to work around or resolve this:

  • Use a type assertion on the plugin:
    plugins: [
      stripe({ ... }) as unknown as BetterAuthPlugin,
    ]
    
  • Use explicit type annotations for your config and the result of betterAuth:
    import { betterAuth, BetterAuthOptions } from "better-auth";
    const authConfig = { ... } satisfies BetterAuthOptions;
    export const auth = betterAuth(authConfig) as ReturnType<typeof betterAuth<typeof authConfig>>;
    
  • If you have "composite" or "declaration" set to true in your tsconfig.json, try setting them to false (if you don't need type declarations).

Recent PRs have improved plugin typing and fixed related issues, including in the stripe plugin3 4 . If possible, update to the latest Better Auth version to benefit from these fixes.

The error does not affect runtime functionality—it's a TypeScript typing issue only. The plugin will still work as expected at runtime.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3231850049 --> @dosubot[bot] commented on GitHub (Aug 28, 2025): <!-- Answer --> This TypeScript error is caused by a deep type incompatibility between the stripe plugin and the BetterAuthPlugin interface, especially in the init property and related types. This is a known issue when using certain plugins or after upgrading to newer Better Auth versions with stricter typing. The root cause is often mismatched or duplicated type definitions across the codebase and plugins, sometimes exacerbated by differences in how types are imported or resolved by TypeScript[^1][^2]. You have a few options to work around or resolve this: - Use a type assertion on the plugin: ```ts plugins: [ stripe({ ... }) as unknown as BetterAuthPlugin, ] ``` - Use explicit type annotations for your config and the result of betterAuth: ```ts import { betterAuth, BetterAuthOptions } from "better-auth"; const authConfig = { ... } satisfies BetterAuthOptions; export const auth = betterAuth(authConfig) as ReturnType<typeof betterAuth<typeof authConfig>>; ``` - If you have "composite" or "declaration" set to true in your tsconfig.json, try setting them to false (if you don't need type declarations). Recent PRs have improved plugin typing and fixed related issues, including in the stripe plugin[^3][^4]. If possible, update to the latest Better Auth version to benefit from these fixes. The error does not affect runtime functionality—it's a TypeScript typing issue only. The plugin will still work as expected at runtime. [^1]: [TypeScript plugin type error discussion](https://github.com/better-auth/better-auth/issues/3067) [^2]: [Known plugin typing issues](https://github.com/better-auth/better-auth/issues/4266) [^3]: [Stripe plugin typing fix PR](https://github.com/better-auth/better-auth/pull/4037) [^4]: [Type error fix PR](https://github.com/better-auth/better-auth/pull/3653) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/8fa5ccc8-68ed-487d-8ddc-6387cec66bc7?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/8fa5ccc8-68ed-487d-8ddc-6387cec66bc7?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/8fa5ccc8-68ed-487d-8ddc-6387cec66bc7?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/8fa5ccc8-68ed-487d-8ddc-6387cec66bc7?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/8fa5ccc8-68ed-487d-8ddc-6387cec66bc7?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/8fa5ccc8-68ed-487d-8ddc-6387cec66bc7?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/8fa5ccc8-68ed-487d-8ddc-6387cec66bc7?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4279)
Author
Owner

@himself65 commented on GitHub (Aug 28, 2025):

related code: https://github.com/LMRouter/lmrouter/blob/feature/auth/src/utils/auth.ts#L56-L60

<!-- gh-comment-id:3231877622 --> @himself65 commented on GitHub (Aug 28, 2025): related code: https://github.com/LMRouter/lmrouter/blob/feature/auth/src/utils/auth.ts#L56-L60
Author
Owner

@yvbbrjdr commented on GitHub (Aug 28, 2025):

permalink: 4de6093b0f/src/utils/auth.ts (L56-L60)

<!-- gh-comment-id:3232368648 --> @yvbbrjdr commented on GitHub (Aug 28, 2025): permalink: https://github.com/LMRouter/lmrouter/blob/4de6093b0fdcb890b9b57bb8129786ee38748aec/src/utils/auth.ts#L56-L60
Author
Owner

@himself65 commented on GitHub (Aug 28, 2025):

Fixed in 1.3.8-beta.6

<!-- gh-comment-id:3234343930 --> @himself65 commented on GitHub (Aug 28, 2025): Fixed in 1.3.8-beta.6
Author
Owner

@himself65 commented on GitHub (Aug 28, 2025):

8448c0a676

<!-- gh-comment-id:3234343992 --> @himself65 commented on GitHub (Aug 28, 2025): https://github.com/LMRouter/lmrouter/commit/8448c0a6760ec8093a9db545aea1ee5e3801e23a
Author
Owner

@vladaman commented on GitHub (Aug 31, 2025):

Fixed in 1.3.8-beta.6

Seems like "better-auth": "1.3.8-beta.6", is not compatible with "@better-auth/stripe": "^1.3.7",

 bun add @better-auth/stripe:1.3.8-beta.6                                                                                                     16:00:06
[0.11ms] ".env.local"
bun add v1.2.21 (7c45ed97)
  🔍 Resolving [1/1] error: "git clone" for "@better-auth/stripe:1.3.8-beta.6" failed
error: InstallFailed cloning repository for @better-auth/stripe:1.3.8-beta.6
error: @better-auth/stripe:1.3.8-beta.6 failed to resolve
<!-- gh-comment-id:3240166799 --> @vladaman commented on GitHub (Aug 31, 2025): > Fixed in 1.3.8-beta.6 Seems like `"better-auth": "1.3.8-beta.6",` is not compatible with `"@better-auth/stripe": "^1.3.7",` ``` bun add @better-auth/stripe:1.3.8-beta.6 16:00:06 [0.11ms] ".env.local" bun add v1.2.21 (7c45ed97) 🔍 Resolving [1/1] error: "git clone" for "@better-auth/stripe:1.3.8-beta.6" failed error: InstallFailed cloning repository for @better-auth/stripe:1.3.8-beta.6 error: @better-auth/stripe:1.3.8-beta.6 failed to resolve ```
Author
Owner

@himself65 commented on GitHub (Sep 1, 2025):

Fixed in 1.3.8-beta.6

Seems like "better-auth": "1.3.8-beta.6", is not compatible with "@better-auth/stripe": "^1.3.7",

 bun add @better-auth/stripe:1.3.8-beta.6                                                                                                     16:00:06
[0.11ms] ".env.local"
bun add v1.2.21 (7c45ed97)
  🔍 Resolving [1/1] error: "git clone" for "@better-auth/stripe:1.3.8-beta.6" failed
error: InstallFailed cloning repository for @better-auth/stripe:1.3.8-beta.6
error: @better-auth/stripe:1.3.8-beta.6 failed to resolve

Yeah you need same version for stripe package

<!-- gh-comment-id:3243176984 --> @himself65 commented on GitHub (Sep 1, 2025): > > Fixed in 1.3.8-beta.6 > > Seems like `"better-auth": "1.3.8-beta.6",` is not compatible with `"@better-auth/stripe": "^1.3.7",` > > ``` > bun add @better-auth/stripe:1.3.8-beta.6 16:00:06 > [0.11ms] ".env.local" > bun add v1.2.21 (7c45ed97) > 🔍 Resolving [1/1] error: "git clone" for "@better-auth/stripe:1.3.8-beta.6" failed > error: InstallFailed cloning repository for @better-auth/stripe:1.3.8-beta.6 > error: @better-auth/stripe:1.3.8-beta.6 failed to resolve > ``` Yeah you need same version for stripe package
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#27208