[GH-ISSUE #4556] Expo plugin type error #27303

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

Originally created by @bbxst on GitHub (Sep 10, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/4556

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

import { betterAuth } from "better-auth";
import { expo } from "@better-auth/expo";

export const auth = betterAuth({
  plugins: [expo()]
});
"dependencies": {
  "@better-auth/expo": "1.3.9",
  "@hono/node-server": "1.19.0",
  "@neondatabase/serverless": "1.0.1",
  "better-auth": "1.3.9",
  "drizzle-orm": "0.44.5",
  "hono": "4.9.6"
},

Current vs. Expected behavior

Type 'import("/node_modules/better-auth/dist/shared/better-auth.tThsKLej", { with: { "resolution-mode": "import" } }).G | undefined' is not assignable to type 'import("/node_modules/better-auth/dist/shared/better-auth.BWDlmABj").G | undefined'.

Type 'GenericEndpointContext' is not assignable to type 'GenericEndpointContext | undefined'.ts(2322)

What version of Better Auth are you using?

1.3.9

System info

{
  "system": {
    "platform": "win32",
    "arch": "x64",
    "version": "Windows 11 Home Single Language",
    "release": "10.0.26100",
    "cpuCount": 16,
    "cpuModel": "AMD Ryzen 7 5800H with Radeon Graphics         ",
    "totalMemory": "15.40 GB",
    "freeMemory": "7.30 GB"
  },
  "node": {
    "version": "v20.19.4",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.4.2"
  },
  "frameworks": [
    {
      "name": "hono",
      "version": "4.9.6"
    }
  ],
  "databases": [
    {
      "name": "drizzle",
      "version": "0.44.5"
    },
    {
      "name": "@neondatabase/serverless",
      "version": "1.0.1"
    }
  ],
  "betterAuth": {
    "version": "Unknown",
    "config": {
      "plugins": [
        {
          "name": "expo",
          "config": {
            "id": "expo",
            "hooks": {
              "after": [
                {}
              ]
            }
          }
        }
      ]
    }
  }
}

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

Backend, Types, Package

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { expo } from "@better-auth/expo";

export const auth = betterAuth({
  plugins: [expo()]
});

Additional context

No response

Originally created by @bbxst on GitHub (Sep 10, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/4556 ### Is this suited for github? - [ ] Yes, this is suited for github ### To Reproduce ```typescript import { betterAuth } from "better-auth"; import { expo } from "@better-auth/expo"; export const auth = betterAuth({ plugins: [expo()] }); ``` ``` "dependencies": { "@better-auth/expo": "1.3.9", "@hono/node-server": "1.19.0", "@neondatabase/serverless": "1.0.1", "better-auth": "1.3.9", "drizzle-orm": "0.44.5", "hono": "4.9.6" }, ``` ### Current vs. Expected behavior Type 'import("/node_modules/better-auth/dist/shared/better-auth.tThsKLej", { with: { "resolution-mode": "import" } }).G | undefined' is not assignable to type 'import("/node_modules/better-auth/dist/shared/better-auth.BWDlmABj").G | undefined'. Type 'GenericEndpointContext' is not assignable to type 'GenericEndpointContext | undefined'.ts(2322) ### What version of Better Auth are you using? 1.3.9 ### System info ```bash { "system": { "platform": "win32", "arch": "x64", "version": "Windows 11 Home Single Language", "release": "10.0.26100", "cpuCount": 16, "cpuModel": "AMD Ryzen 7 5800H with Radeon Graphics ", "totalMemory": "15.40 GB", "freeMemory": "7.30 GB" }, "node": { "version": "v20.19.4", "env": "development" }, "packageManager": { "name": "npm", "version": "11.4.2" }, "frameworks": [ { "name": "hono", "version": "4.9.6" } ], "databases": [ { "name": "drizzle", "version": "0.44.5" }, { "name": "@neondatabase/serverless", "version": "1.0.1" } ], "betterAuth": { "version": "Unknown", "config": { "plugins": [ { "name": "expo", "config": { "id": "expo", "hooks": { "after": [ {} ] } } } ] } } } ``` ### Which area(s) are affected? (Select all that apply) Backend, Types, Package ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { expo } from "@better-auth/expo"; export const auth = betterAuth({ plugins: [expo()] }); ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-17 18:14:17 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 10, 2025):

Hi @bbxst! I'm Dosu and I’m helping the better-auth team.

This is a known TypeScript issue with Better Auth plugins, including @better-auth/expo. The error happens because TypeScript sees types like GenericEndpointContext as different when they're imported from distinct module paths—usually due to multiple copies of better-auth in node_modules, mismatched versions, or workspace hoisting issues. This is common in monorepos or when plugins and core aren't perfectly in sync [example].

How to fix:

  1. Explicit type annotation:
    Use the satisfies keyword and ReturnType utility to type your auth instance. Example:

    import { betterAuth, BetterAuthOptions } from "better-auth";
    import { expo } from "@better-auth/expo";
    
    const authConfig = {
      plugins: [expo()]
    } satisfies BetterAuthOptions;
    
    export const auth = betterAuth(authConfig) as ReturnType<typeof betterAuth<typeof authConfig>>;
    

    This resolves most plugin type errors [details].

  2. Check your node_modules:
    Make sure you only have one copy of better-auth and @better-auth/expo. Delete node_modules and your lockfile, then reinstall.

  3. tsconfig.json tweaks:
    If you use "composite" or "declaration" in tsconfig, try setting them to false if you don't need type declarations [details].

  4. Keep versions in sync:
    Always use matching patch versions for better-auth and its plugins. Recent type export changes (see PRs #3653, #3546) mean mismatches can cause new type errors.

Note:
This is a TypeScript typing issue only—your code will run fine at runtime.

If you still see the error after these steps, check for duplicate better-auth folders in node_modules and ensure all packages use the exact same version.

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:3273733853 --> @dosubot[bot] commented on GitHub (Sep 10, 2025): <!-- Greeting --> Hi @bbxst! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This is a known TypeScript issue with Better Auth plugins, including @better-auth/expo. The error happens because TypeScript sees types like `GenericEndpointContext` as different when they're imported from distinct module paths—usually due to multiple copies of better-auth in node_modules, mismatched versions, or workspace hoisting issues. This is common in monorepos or when plugins and core aren't perfectly in sync [[example](https://github.com/better-auth/better-auth/issues/4250)]. **How to fix:** 1. **Explicit type annotation:** Use the `satisfies` keyword and `ReturnType` utility to type your auth instance. Example: ```typescript import { betterAuth, BetterAuthOptions } from "better-auth"; import { expo } from "@better-auth/expo"; const authConfig = { plugins: [expo()] } satisfies BetterAuthOptions; export const auth = betterAuth(authConfig) as ReturnType<typeof betterAuth<typeof authConfig>>; ``` This resolves most plugin type errors [[details](https://github.com/better-auth/better-auth/issues/3067)]. 2. **Check your node_modules:** Make sure you only have one copy of better-auth and @better-auth/expo. Delete node_modules and your lockfile, then reinstall. 3. **tsconfig.json tweaks:** If you use `"composite"` or `"declaration"` in tsconfig, try setting them to `false` if you don't need type declarations [[details](https://github.com/better-auth/better-auth/issues/4279)]. 4. **Keep versions in sync:** Always use matching patch versions for better-auth and its plugins. Recent type export changes (see PRs [#3653](https://github.com/better-auth/better-auth/pull/3653), [#3546](https://github.com/better-auth/better-auth/pull/3546)) mean mismatches can cause new type errors. **Note:** This is a TypeScript typing issue only—your code will run fine at runtime. If you still see the error after these steps, check for duplicate better-auth folders in node_modules and ensure all packages use the exact same version. <!-- 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/c30dbbdc-6d56-425e-9791-c924c68dea25?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/c30dbbdc-6d56-425e-9791-c924c68dea25?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/c30dbbdc-6d56-425e-9791-c924c68dea25?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/c30dbbdc-6d56-425e-9791-c924c68dea25?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/c30dbbdc-6d56-425e-9791-c924c68dea25?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/c30dbbdc-6d56-425e-9791-c924c68dea25?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/c30dbbdc-6d56-425e-9791-c924c68dea25?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/4556)
Author
Owner

@bbxst commented on GitHub (Sep 10, 2025):

Hi @bbxst! I'm Dosu and I’m helping the better-auth team.

This is a known TypeScript issue with Better Auth plugins, including @better-auth/expo. The error happens because TypeScript sees types like GenericEndpointContext as different when they're imported from distinct module paths—usually due to multiple copies of better-auth in node_modules, mismatched versions, or workspace hoisting issues. This is common in monorepos or when plugins and core aren't perfectly in sync [example].

How to fix:

  1. Explicit type annotation:
    Use the satisfies keyword and ReturnType utility to type your auth instance. Example:
    import { betterAuth, BetterAuthOptions } from "better-auth";
    import { expo } from "@better-auth/expo";

    const authConfig = {
    plugins: [expo()]
    } satisfies BetterAuthOptions;

    export const auth = betterAuth(authConfig) as ReturnType<typeof betterAuth>;

    This resolves most plugin type errors [details].

  2. Check your node_modules:
    Make sure you only have one copy of better-auth and @better-auth/expo. Delete node_modules and your lockfile, then reinstall.

  3. tsconfig.json tweaks:
    If you use "composite" or "declaration" in tsconfig, try setting them to false if you don't need type declarations [details].

  4. Keep versions in sync:
    Always use matching patch versions for better-auth and its plugins. Recent type export changes (see PRs #3653, #3546) mean mismatches can cause new type errors.

Note: This is a TypeScript typing issue only—your code will run fine at runtime.

If you still see the error after these steps, check for duplicate better-auth folders in node_modules and ensure all packages use the exact same version.

To reply, just mention @dosu.

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

This doesn't work for me

<!-- gh-comment-id:3273764760 --> @bbxst commented on GitHub (Sep 10, 2025): > Hi [@bbxst](https://github.com/bbxst)! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. > > This is a known TypeScript issue with Better Auth plugins, including @better-auth/expo. The error happens because TypeScript sees types like `GenericEndpointContext` as different when they're imported from distinct module paths—usually due to multiple copies of better-auth in node_modules, mismatched versions, or workspace hoisting issues. This is common in monorepos or when plugins and core aren't perfectly in sync [[example](https://github.com/better-auth/better-auth/issues/4250)]. > > **How to fix:** > > 1. **Explicit type annotation:** > Use the `satisfies` keyword and `ReturnType` utility to type your auth instance. Example: > import { betterAuth, BetterAuthOptions } from "better-auth"; > import { expo } from "@better-auth/expo"; > > const authConfig = { > plugins: [expo()] > } satisfies BetterAuthOptions; > > export const auth = betterAuth(authConfig) as ReturnType<typeof betterAuth<typeof authConfig>>; > > > > > > > > > > This resolves most plugin type errors [[details](https://github.com/better-auth/better-auth/issues/3067)]. > 2. **Check your node_modules:** > Make sure you only have one copy of better-auth and @better-auth/expo. Delete node_modules and your lockfile, then reinstall. > 3. **tsconfig.json tweaks:** > If you use `"composite"` or `"declaration"` in tsconfig, try setting them to `false` if you don't need type declarations [[details](https://github.com/better-auth/better-auth/issues/4279)]. > 4. **Keep versions in sync:** > Always use matching patch versions for better-auth and its plugins. Recent type export changes (see PRs [#3653](https://github.com/better-auth/better-auth/pull/3653), [#3546](https://github.com/better-auth/better-auth/pull/3546)) mean mismatches can cause new type errors. > > **Note:** This is a TypeScript typing issue only—your code will run fine at runtime. > > If you still see the error after these steps, check for duplicate better-auth folders in node_modules and ensure all packages use the exact same version. > > _To reply, just mention [@dosu](https://go.dosu.dev/dosubot)._ > > How did I do? [Good](https://app.dosu.dev/response-feedback/c30dbbdc-6d56-425e-9791-c924c68dea25?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/c30dbbdc-6d56-425e-9791-c924c68dea25?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/c30dbbdc-6d56-425e-9791-c924c68dea25?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/c30dbbdc-6d56-425e-9791-c924c68dea25?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/c30dbbdc-6d56-425e-9791-c924c68dea25?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/c30dbbdc-6d56-425e-9791-c924c68dea25?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/c30dbbdc-6d56-425e-9791-c924c68dea25?feedback_type=other)  [![Chat with Dosu](https://camo.githubusercontent.com/d9ffebb979729c9ef0fc4e3090dbae5b17cabbfec8afe378ada6b81913d6ad8a/68747470733a2f2f646f73752e6465762f646f73752d636861742d62616467652e737667)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github) [![Join Discord](https://camo.githubusercontent.com/d562c2df5e4567ea41d37f1d91a4da0839d8341037045b103b2da268998de17f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6a6f696e2d3538363546323f6c6f676f3d646973636f7264266c6f676f436f6c6f723d7768697465266c6162656c3d)](https://go.dosu.dev/discord-bot) [![Share on X](https://camo.githubusercontent.com/4649f705e2396d6f328dbc8e800a0509c9c17b3b20253b36706c393df124b93d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f582d73686172652d626c61636b)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4556) This doesn't work for me
Author
Owner

@bbxst commented on GitHub (Sep 10, 2025):

plugins: [
expo() as unknown as BetterAuthPlugin,
]

this fixed

<!-- gh-comment-id:3273779094 --> @bbxst commented on GitHub (Sep 10, 2025): plugins: [ expo() as unknown as BetterAuthPlugin, ] this fixed
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#27303