[GH-ISSUE #8302] dash plugin from @better-auth/infra incompatible with exactOptionalPropertyTypes #11050

Closed
opened 2026-04-13 07:25:37 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @nihalgonsalves on GitHub (Mar 2, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/8302

Originally assigned to: @himself65 on GitHub.

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Installed packages:

"@better-auth/drizzle-adapter": "^1.5.1",
"@better-auth/infra": "^0.1.8",
"better-auth": "^1.5.1",

Minimal config for error:

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

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

Current vs. Expected behavior

Current behaviour – TypeScript error:

src/lib/auth.ts:25:12 - error TS2322: Type '{ id: "dash"; init(ctx: AuthContext): { options: { databaseHooks: { user: { create: { after(user: { id: string; createdAt: Date; updatedAt: Date; email: string; emailVerified: boolean; name: string; image?: string | ... 1 more ... | undefined; } & Record<...>, _ctx: GenericEndpointContext | null): Promise<...>; }; u...' is not assignable to type 'BetterAuthPlugin'.
  Type '{ id: "dash"; init(ctx: AuthContext): { options: { databaseHooks: { user: { create: { after(user: { id: string; createdAt: Date; updatedAt: Date; email: string; emailVerified: boolean; name: string; image?: string | ... 1 more ... | undefined; } & Record<...>, _ctx: GenericEndpointContext | null): Promise<...>; }; u...' is not assignable to type '{ id: LiteralString; init?: ((ctx: AuthContext) => void | Awaitable<{ context?: { session?: { session?: { [x: string]: any; id?: string; createdAt?: { toString?: () => string; toDateString?: () => string; ... 42 more ...; [Symbol.toPrimitive]?: { ...; }; }; ... 5 more ...; userAgent?: string | ... 1 more ... | undef...'.
    Types of property 'schema' are incompatible.
      Type '{ user?: { fields: { lastActiveAt: { type: "date"; }; }; } | undefined; }' is not assignable to type 'BetterAuthPluginDBSchema'.
        Property 'user' is incompatible with index signature.
          Type '{ fields: { lastActiveAt: { type: "date"; }; }; } | undefined' is not assignable to type '{ fields: { [field: string]: DBFieldAttribute; }; disableMigration?: boolean | undefined; modelName?: string | undefined; }'.
            Type 'undefined' is not assignable to type '{ fields: { [field: string]: DBFieldAttribute; }; disableMigration?: boolean | undefined; modelName?: string | undefined; }'.

25  plugins: [dash()],
              ~~~~~~

Expected behaviour: types are compatible

What version of Better Auth are you using?

1.5.1

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.3.0: Wed Jan 28 20:53:05 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T6020",
    "release": "25.3.0",
    "cpuCount": 12,
    "cpuModel": "Apple M2 Max",
    "totalMemory": "32.00 GB",
    "freeMemory": "0.82 GB"
  },
  "node": {
    "version": "v24.14.0",
    "env": "development"
  },
  "packageManager": {
    "name": "pnpm",
    "version": "10.30.3"
  },
  "frameworks": [
    {
      "name": "react",
      "version": "19.2.4"
    },
    {
      "name": "hono",
      "version": "^4.12.3"
    }
  ],
  "databases": [
    {
      "name": "drizzle",
      "version": "0.45.1"
    }
  ],
  "betterAuth": {
    "version": "^1.5.1",
    "config": {
      "plugins": [
        {
          "name": "dash",
          "config": {
            "id": "dash",
            "hooks": {
              "before": [
                {}
              ],
              "after": [
                {},
                {}
              ]
            },
            "endpoints": {},
            "schema": {}
          }
        }
      ]
    }
  }
}

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

Types

Auth config (if applicable)

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

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

Additional context

No response

Originally created by @nihalgonsalves on GitHub (Mar 2, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/8302 Originally assigned to: @himself65 on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Installed packages: ```json "@better-auth/drizzle-adapter": "^1.5.1", "@better-auth/infra": "^0.1.8", "better-auth": "^1.5.1", ``` Minimal config for error: ```ts import { betterAuth } from "better-auth"; import { dash } from "@better-auth/infra"; export const auth = betterAuth({ plugins: [dash()], }); ``` ### Current vs. Expected behavior Current behaviour – TypeScript error: ``` src/lib/auth.ts:25:12 - error TS2322: Type '{ id: "dash"; init(ctx: AuthContext): { options: { databaseHooks: { user: { create: { after(user: { id: string; createdAt: Date; updatedAt: Date; email: string; emailVerified: boolean; name: string; image?: string | ... 1 more ... | undefined; } & Record<...>, _ctx: GenericEndpointContext | null): Promise<...>; }; u...' is not assignable to type 'BetterAuthPlugin'. Type '{ id: "dash"; init(ctx: AuthContext): { options: { databaseHooks: { user: { create: { after(user: { id: string; createdAt: Date; updatedAt: Date; email: string; emailVerified: boolean; name: string; image?: string | ... 1 more ... | undefined; } & Record<...>, _ctx: GenericEndpointContext | null): Promise<...>; }; u...' is not assignable to type '{ id: LiteralString; init?: ((ctx: AuthContext) => void | Awaitable<{ context?: { session?: { session?: { [x: string]: any; id?: string; createdAt?: { toString?: () => string; toDateString?: () => string; ... 42 more ...; [Symbol.toPrimitive]?: { ...; }; }; ... 5 more ...; userAgent?: string | ... 1 more ... | undef...'. Types of property 'schema' are incompatible. Type '{ user?: { fields: { lastActiveAt: { type: "date"; }; }; } | undefined; }' is not assignable to type 'BetterAuthPluginDBSchema'. Property 'user' is incompatible with index signature. Type '{ fields: { lastActiveAt: { type: "date"; }; }; } | undefined' is not assignable to type '{ fields: { [field: string]: DBFieldAttribute; }; disableMigration?: boolean | undefined; modelName?: string | undefined; }'. Type 'undefined' is not assignable to type '{ fields: { [field: string]: DBFieldAttribute; }; disableMigration?: boolean | undefined; modelName?: string | undefined; }'. 25 plugins: [dash()], ~~~~~~ ``` Expected behaviour: types are compatible ### What version of Better Auth are you using? 1.5.1 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.3.0: Wed Jan 28 20:53:05 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T6020", "release": "25.3.0", "cpuCount": 12, "cpuModel": "Apple M2 Max", "totalMemory": "32.00 GB", "freeMemory": "0.82 GB" }, "node": { "version": "v24.14.0", "env": "development" }, "packageManager": { "name": "pnpm", "version": "10.30.3" }, "frameworks": [ { "name": "react", "version": "19.2.4" }, { "name": "hono", "version": "^4.12.3" } ], "databases": [ { "name": "drizzle", "version": "0.45.1" } ], "betterAuth": { "version": "^1.5.1", "config": { "plugins": [ { "name": "dash", "config": { "id": "dash", "hooks": { "before": [ {} ], "after": [ {}, {} ] }, "endpoints": {}, "schema": {} } } ] } } } ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { dash } from "@better-auth/infra"; export const auth = betterAuth({ plugins: [dash()], }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-13 07:25:37 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 2, 2026):

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

This appears to be a type incompatibility in the dash plugin's schema definition. The error occurs because @better-auth/infra's dash plugin defines an optional table (user?: { ... }), but BetterAuthPluginDBSchema requires all tables to be non-optional properties:

export type BetterAuthPluginDBSchema = {
  [table in string]: {  // Tables must be required (not optional)
    fields: { [field: string]: DBFieldAttribute; };
    disableMigration?: boolean;
    modelName?: string;
  };
};

The @better-auth/infra package is separate from the core better-auth repository, so this is likely a bug in that package that needs to be fixed there. The fix would be to change the schema from:

schema: {
  user?: { fields: { lastActiveAt: { type: "date" } } }  // ❌ Optional table
}

To:

schema: {
  user: {  // ✅ Required table
    fields: {
      lastActiveAt: { type: "date", required: false }  // Optional field
    }
  }
}

Better Auth has recently centralized plugin schema types, which may have introduced stricter requirements that the infra package hasn't been updated to match.

Workaround: You may need to open an issue in the @better-auth/infra repository or use a type assertion as a temporary fix:

import { dash } from "@better-auth/infra";

export const auth = betterAuth({
  plugins: [dash() as any],  // Temporary workaround
});

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:3986896019 --> @dosubot[bot] commented on GitHub (Mar 2, 2026): <!-- Greeting --> Hi @nihalgonsalves! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This appears to be a type incompatibility in the `dash` plugin's schema definition. The error occurs because `@better-auth/infra`'s dash plugin defines an optional table (`user?: { ... }`), but [BetterAuthPluginDBSchema](https://github.com/better-auth/better-auth/blob/cb6939df748448cb5b2d48c5a929cb5b31692710/packages/core/src/db/plugin.ts#L3-L11) requires all tables to be non-optional properties: ```typescript export type BetterAuthPluginDBSchema = { [table in string]: { // Tables must be required (not optional) fields: { [field: string]: DBFieldAttribute; }; disableMigration?: boolean; modelName?: string; }; }; ``` The `@better-auth/infra` package is separate from the core better-auth repository, so this is likely a bug in that package that needs to be fixed there. The fix would be to change the schema from: ```typescript schema: { user?: { fields: { lastActiveAt: { type: "date" } } } // ❌ Optional table } ``` To: ```typescript schema: { user: { // ✅ Required table fields: { lastActiveAt: { type: "date", required: false } // Optional field } } } ``` Better Auth has [recently centralized plugin schema types](https://github.com/better-auth/better-auth/pull/5092), which may have introduced stricter requirements that the infra package hasn't been updated to match. **Workaround**: You may need to open an issue in the `@better-auth/infra` repository or use a type assertion as a temporary fix: ```typescript import { dash } from "@better-auth/infra"; export const auth = betterAuth({ plugins: [dash() as any], // Temporary workaround }); ``` <!-- 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/d1a10781-95f6-42b7-92bd-6acb0c2fa58b?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/d1a10781-95f6-42b7-92bd-6acb0c2fa58b?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/d1a10781-95f6-42b7-92bd-6acb0c2fa58b?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/d1a10781-95f6-42b7-92bd-6acb0c2fa58b?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/d1a10781-95f6-42b7-92bd-6acb0c2fa58b?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/d1a10781-95f6-42b7-92bd-6acb0c2fa58b?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/d1a10781-95f6-42b7-92bd-6acb0c2fa58b?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20appears%20to%20be%20a%20type%20incompatibility%20in%20the%20%60dash%60%20plugin%27s%20schema%20definition.%20The%20error%20occurs%20because%20%60%40better-auth/infra%60%27s%20dash%20plugin%20defines%20an%20optional%20table%20%28%60user%3F%3A%20%7B%20...%20%7D%60%29%2C%20but%20%5BBetterAuthPluginDBSchema%5D%28https%3A//github.com/better-auth/better-auth/blob/cb6939df748448cb5b2d48c5a929cb5b31692710/packages/core/src/db/plugin.ts%23L3-L11%29%20requires%20all%20tables%20to%20be%20non-optional%20properties%3A%0A%0A%60%60%60typescript%0Aexport%20type%20BetterAuthPluginDBSchema%20%3D%20%7B%0A%20%20%5Btable%20in%20string%5D%3A%20%7B%20%20//%20Tables%20must%20be%20required%20%28not%20optional%29%0A%20%20%20%20fields%3A%20%7B%20%5Bfield%3A%20string%5D%3A%20DBFieldAttribute%3B%20%7D%3B%0A%20%20%20%20disableMigration%3F%3A%20boolean%3B%0A%20%20%20%20modelName%3F%3A%20string%3B%0A%20%20%7D%3B%0A%7D%3B%0A%60%60%60%0A%0AThe%20%60%40better-auth/infra%60%20package%20is%20separate%20from%20the%20core%20better-auth%20repository%2C%20so%20this%20is%20likely%20a%20bug%20in%20that%20package%20that%20needs%20to%20be%20fixed%20there.%20The%20fix%20would%20be%20to%20change%20the%20schema%20from%3A%0A%0A%60%60%60typescript%0Aschema%3A%20%7B%0A%20%20user%3F%3A%20%7B%20fields%3A%20%7B%20lastActiveAt%3A%20%7B%20type%3A%20%22date%22%20%7D%20%7D%20%7D%20%20//%20%E2%9D%8C%20Optional%20table%0A%7D%0A%60%60%60%0A%0ATo%3A%0A%0A%60%60%60typescript%0Aschema%3A%20%7B%0A%20%20user%3A%20%7B%20%20//%20%E2%9C%85%20Required%20table%0A%20%20%20%20fields%3A%20%7B%0A%20%20%20%20%20%20lastActiveAt%3A%20%7B%20type%3A%20%22date%22%2C%20required%3A%20false%20%7D%20%20//%20Optional%20field%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A%60%60%60%0A%0ABetter%20Auth%20has%20%5Brecently%20centralized%20plugin%20schema%20types%5D%28https%3A//github.com/better-auth/better-auth/pull/5092%29%2C%20which%20may%20have%20introduced%20stricter%20requirements%20that%20the%20infra%20package%20hasn%27t%20been%20updated%20to%20match.%0A%0A%2A%2AWorkaround%2A%2A%3A%20You%20may%20need%20to%20open%20an%20issue%20in%20the%20%60%40better-auth/infra%60%20repository%20or%20use%20a%20type%20assertion%20as%20a%20temporary%20fix%3A%0A%0A%60%60%60typescript%0Aimport%20%7B%20dash%20%7D%20from%20%22%40better-auth/infra%22%3B%0A%0Aexport%20const%20auth%20%3D%20betterAuth%28%7B%0A%20%20plugins%3A%20%5Bdash%28%29%20as%20any%5D%2C%20%20//%20Temporary%20workaround%0A%7D%29%3B%0A%60%60%60)&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/8302)
Author
Owner

@bytaesu commented on GitHub (Mar 2, 2026):

Hi @nihalgonsalves,

I tested the version you provided and wasn't able to reproduce the issue. Could you try removing node_modules or restarting the TS Server?

Image
<!-- gh-comment-id:3987049791 --> @bytaesu commented on GitHub (Mar 2, 2026): Hi @nihalgonsalves, I tested the version you provided and wasn't able to reproduce the issue. Could you try removing node_modules or restarting the TS Server? <img width="600" alt="Image" src="https://github.com/user-attachments/assets/f3e1fbb2-5dc8-4dad-96df-cec13b65f0b9" />
Author
Owner

@nihalgonsalves commented on GitHub (Mar 2, 2026):

@bytaesu thanks for checking! – sorry, it looks like the tsconfig.json was important. It seems to be specifically the exactOptionalPropertyTypes flag that causes the problem; this config is enough to trigger it:

{
  "compilerOptions": {
    "strict": true,
    "exactOptionalPropertyTypes": true
  }
}

(exactOptionalPropertyTypes comes enabled with @tsconfig/strictest by default)

<!-- gh-comment-id:3987152910 --> @nihalgonsalves commented on GitHub (Mar 2, 2026): @bytaesu thanks for checking! – sorry, it looks like the `tsconfig.json` was important. It seems to be specifically the `exactOptionalPropertyTypes` flag that causes the problem; this config is enough to trigger it: ```json { "compilerOptions": { "strict": true, "exactOptionalPropertyTypes": true } } ``` (`exactOptionalPropertyTypes` comes enabled with `@tsconfig/strictest` by default)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#11050