[GH-ISSUE #6491] Support "exactOptionalPropertyTypes": true in tsconfig.json #10533

Closed
opened 2026-04-13 06:44:43 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @lensbart on GitHub (Dec 3, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/6491

Hello,

First of all, thanks for developing and maintaining this well-designed library.

There have been several issues with having "exactOptionalPropertyTypes": true in tsconfig.json. It would be great if Better Auth would support this setting by default.

Currently, the oidcProvider plugin has type errors with exactOptionalPropertyTypes enabled. Previously, the organization plugin had a similar issue. There are currently 6 open issues that reference this setting: https://github.com/better-auth/better-auth/issues?q=is%3Aissue%20exactOptionalPropertyTypes

Maybe better-auth would be more robust if its tsconfig.base.json would have "exactOptionalPropertyTypes": true as well.

Thanks for your attention to this matter!

Current vs. Expected behavior

Type errors when including oidcProvider in the plugins array

What version of Better Auth are you using?

1.4.4

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.1.0: Mon Oct 20 19:30:01 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6031",
    "release": "25.1.0",
    "cpuCount": 16,
    "cpuModel": "Apple M3 Max",
    "totalMemory": "64.00 GB",
    "freeMemory": "0.63 GB"
  },
  "node": {
    "version": "v24.9.0",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.6.0"
  },
  "frameworks": [
    {
      "name": "react",
      "version": "^19.2.0"
    }
  ],
  "databases": [
    {
      "name": "pg",
      "version": "^8.16.3"
    },
    {
      "name": "drizzle",
      "version": "^0.44.7"
    }
  ],
  "betterAuth": {
    "version": "^1.4.4",
    "config": null
  }
}

Which area(s) are affected?

Types

Originally created by @lensbart on GitHub (Dec 3, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/6491 Hello, First of all, thanks for developing and maintaining this well-designed library. There have been several issues with having `"exactOptionalPropertyTypes": true` in `tsconfig.json`. It would be great if Better Auth would support this setting by default. Currently, the `oidcProvider` plugin has type errors with `exactOptionalPropertyTypes` enabled. Previously, the `organization` plugin had a similar issue. There are currently 6 open issues that reference this setting: https://github.com/better-auth/better-auth/issues?q=is%3Aissue%20exactOptionalPropertyTypes Maybe better-auth would be more robust if its [`tsconfig.base.json`](https://github.com/better-auth/better-auth/blob/58e886c2029c79ec75d0bdf67934e525925d9767/tsconfig.base.json#L12) would have `"exactOptionalPropertyTypes": true` as well. Thanks for your attention to this matter! ### Current vs. Expected behavior Type errors when including `oidcProvider` in the `plugins` array ### What version of Better Auth are you using? 1.4.4 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.1.0: Mon Oct 20 19:30:01 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6031", "release": "25.1.0", "cpuCount": 16, "cpuModel": "Apple M3 Max", "totalMemory": "64.00 GB", "freeMemory": "0.63 GB" }, "node": { "version": "v24.9.0", "env": "development" }, "packageManager": { "name": "npm", "version": "11.6.0" }, "frameworks": [ { "name": "react", "version": "^19.2.0" } ], "databases": [ { "name": "pg", "version": "^8.16.3" }, { "name": "drizzle", "version": "^0.44.7" } ], "betterAuth": { "version": "^1.4.4", "config": null } } ``` ### Which area(s) are affected? Types
GiteaMirror added the enhancementlocked labels 2026-04-13 06:44:43 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Dec 3, 2025):

(tag @better-auth-agent if you would like an answer from the Agent)

If you need more help, tag @Skyvern in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3606788559 --> @better-auth-agent[bot] commented on GitHub (Dec 3, 2025): (tag @better-auth-agent if you would like an answer from the Agent) _If you need more help, tag @Skyvern in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@dosubot[bot] commented on GitHub (Dec 3, 2025):

Better Auth does not currently enable "exactOptionalPropertyTypes": true in its base TypeScript config—it's set to false in tsconfig.base.json—so strict optional property types are not enforced by default in the library (source).

Historically, enabling this setting has caused type errors in several plugins, including organization, anonymous, username, and especially oidcProvider. The main issue is that many plugin schemas and options use optional properties with | undefined, which conflicts with how TypeScript checks assignments when exactOptionalPropertyTypes is enabled (source). For example, the OIDCOptions interface in oidcProvider has many optional fields typed as T | undefined, which leads to assignment errors and breaks type inference under strict settings.

The organization and email-otp plugins have already been refactored to avoid these issues, and merged PRs have made them compatible with exactOptionalPropertyTypes (organization fix, email-otp fix). There are also e2e test fixtures and type fixes in recent PRs that show ongoing work to support this setting (test fixture PR, type fix PR). However, the oidcProvider plugin is not yet fully compatible and still causes type errors when this flag is enabled.

Workarounds for now include disabling "exactOptionalPropertyTypes", using type assertions like as any, or explicitly annotating types in your code to avoid deep inferred generics (example workaround). These workarounds reduce type safety or type inference, but there is no safer or more idiomatic solution until the plugin types are refactored.

Maintainers are aware of the need for full support and have fixed related issues in some plugins, but as of v1.4.4, "exactOptionalPropertyTypes": true is not yet the default or fully supported across all plugins, especially oidcProvider (maintainer comment). Full support will require further type definition changes, especially in plugins that use many optional properties.

If you need to use this setting now, you may need to rely on the above workarounds until the remaining plugins are updated. If you encounter specific type errors, sharing the exact error messages can help track progress or suggest more targeted workarounds.

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:3606807851 --> @dosubot[bot] commented on GitHub (Dec 3, 2025): <!-- Answer --> Better Auth does not currently enable `"exactOptionalPropertyTypes": true` in its base TypeScript config—it's set to `false` in `tsconfig.base.json`—so strict optional property types are not enforced by default in the library ([source](https://github.com/better-auth/better-auth/blob/bd98735f2a0e63a954f71055e3125cda70cc5b05/tsconfig.base.json#L12-L12)). Historically, enabling this setting has caused type errors in several plugins, including `organization`, `anonymous`, `username`, and especially `oidcProvider`. The main issue is that many plugin schemas and options use optional properties with `| undefined`, which conflicts with how TypeScript checks assignments when `exactOptionalPropertyTypes` is enabled ([source](https://github.com/better-auth/better-auth/blob/bd98735f2a0e63a954f71055e3125cda70cc5b05/packages/better-auth/src/plugins/oidc-provider/types.ts#L4-L170)). For example, the `OIDCOptions` interface in `oidcProvider` has many optional fields typed as `T | undefined`, which leads to assignment errors and breaks type inference under strict settings. The `organization` and `email-otp` plugins have already been refactored to avoid these issues, and merged PRs have made them compatible with `exactOptionalPropertyTypes` ([organization fix](https://github.com/better-auth/better-auth/pull/5337), [email-otp fix](https://github.com/better-auth/better-auth/pull/3961)). There are also e2e test fixtures and type fixes in recent PRs that show ongoing work to support this setting ([test fixture PR](https://github.com/better-auth/better-auth/pull/5286), [type fix PR](https://github.com/better-auth/better-auth/pull/5845)). However, the `oidcProvider` plugin is not yet fully compatible and still causes type errors when this flag is enabled. Workarounds for now include disabling `"exactOptionalPropertyTypes"`, using type assertions like `as any`, or explicitly annotating types in your code to avoid deep inferred generics ([example workaround](https://github.com/better-auth/better-auth/issues/5666)). These workarounds reduce type safety or type inference, but there is no safer or more idiomatic solution until the plugin types are refactored. Maintainers are aware of the need for full support and have fixed related issues in some plugins, but as of v1.4.4, `"exactOptionalPropertyTypes": true` is not yet the default or fully supported across all plugins, especially `oidcProvider` ([maintainer comment](https://github.com/better-auth/better-auth/issues/5159)). Full support will require further type definition changes, especially in plugins that use many optional properties. If you need to use this setting now, you may need to rely on the above workarounds until the remaining plugins are updated. If you encounter specific type errors, sharing the exact error messages can help track progress or suggest more targeted workarounds. <!-- 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/698aa261-bbde-45cc-af3d-a86ff1bda95e?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/698aa261-bbde-45cc-af3d-a86ff1bda95e?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/698aa261-bbde-45cc-af3d-a86ff1bda95e?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/698aa261-bbde-45cc-af3d-a86ff1bda95e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/698aa261-bbde-45cc-af3d-a86ff1bda95e?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/698aa261-bbde-45cc-af3d-a86ff1bda95e?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/698aa261-bbde-45cc-af3d-a86ff1bda95e?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=Better%20Auth%20does%20not%20currently%20enable%20%60%22exactOptionalPropertyTypes%22%3A%20true%60%20in%20its%20base%20TypeScript%20config%E2%80%94it%27s%20set%20to%20%60false%60%20in%20%60tsconfig.base.json%60%E2%80%94so%20strict%20optional%20property%20types%20are%20not%20enforced%20by%20default%20in%20the%20library%20%28%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/blob/bd98735f2a0e63a954f71055e3125cda70cc5b05/tsconfig.base.json%23L12-L12%29%29.%20%0A%0AHistorically%2C%20enabling%20this%20setting%20has%20caused%20type%20errors%20in%20several%20plugins%2C%20including%20%60organization%60%2C%20%60anonymous%60%2C%20%60username%60%2C%20and%20especially%20%60oidcProvider%60.%20The%20main%20issue%20is%20that%20many%20plugin%20schemas%20and%20options%20use%20optional%20properties%20with%20%60%7C%20undefined%60%2C%20which%20conflicts%20with%20how%20TypeScript%20checks%20assignments%20when%20%60exactOptionalPropertyTypes%60%20is%20enabled%20%28%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/blob/bd98735f2a0e63a954f71055e3125cda70cc5b05/packages/better-auth/src/plugins/oidc-provider/types.ts%23L4-L170%29%29.%20For%20example%2C%20the%20%60OIDCOptions%60%20interface%20in%20%60oidcProvider%60%20has%20many%20optional%20fields%20typed%20as%20%60T%20%7C%20undefined%60%2C%20which%20leads%20to%20assignment%20errors%20and%20breaks%20type%20inference%20under%20strict%20settings.%0A%0AThe%20%60organization%60%20and%20%60email-otp%60%20plugins%20have%20already%20been%20refactored%20to%20avoid%20these%20issues%2C%20and%20merged%20PRs%20have%20made%20them%20compatible%20with%20%60exactOptionalPropertyTypes%60%20%28%5Borganization%20fix%5D%28https%3A//github.com/better-auth/better-auth/pull/5337%29%2C%20%5Bemail-otp%20fix%5D%28https%3A//github.com/better-auth/better-auth/pull/3961%29%29.%20There%20are%20also%20e2e%20test%20fixtures%20and%20type%20fixes%20in%20recent%20PRs%20that%20show%20ongoing%20work%20to%20support%20this%20setting%20%28%5Btest%20fixture%20PR%5D%28https%3A//github.com/better-auth/better-auth/pull/5286%29%2C%20%5Btype%20fix%20PR%5D%28https%3A//github.com/better-auth/better-auth/pull/5845%29%29.%20However%2C%20the%20%60oidcProvider%60%20plugin%20is%20not%20yet%20fully%20compatible%20and%20still%20causes%20type%20errors%20when%20this%20flag%20is%20enabled.%0A%0AWorkarounds%20for%20now%20include%20disabling%20%60%22exactOptionalPropertyTypes%22%60%2C%20using%20type%20assertions%20like%20%60as%20any%60%2C%20or%20explicitly%20annotating%20types%20in%20your%20code%20to%20avoid%20deep%20inferred%20generics%20%28%5Bexample%20workaround%5D%28https%3A//github.com/better-auth/better-auth/issues/5666%29%29.%20These%20workarounds%20reduce%20type%20safety%20or%20type%20inference%2C%20but%20there%20is%20no%20safer%20or%20more%20idiomatic%20solution%20until%20the%20plugin%20types%20are%20refactored.%0A%0AMaintainers%20are%20aware%20of%20the%20need%20for%20full%20support%20and%20have%20fixed%20related%20issues%20in%20some%20plugins%2C%20but%20as%20of%20v1.4.4%2C%20%60%22exactOptionalPropertyTypes%22%3A%20true%60%20is%20not%20yet%20the%20default%20or%20fully%20supported%20across%20all%20plugins%2C%20especially%20%60oidcProvider%60%20%28%5Bmaintainer%20comment%5D%28https%3A//github.com/better-auth/better-auth/issues/5159%29%29.%20Full%20support%20will%20require%20further%20type%20definition%20changes%2C%20especially%20in%20plugins%20that%20use%20many%20optional%20properties.%0A%0AIf%20you%20need%20to%20use%20this%20setting%20now%2C%20you%20may%20need%20to%20rely%20on%20the%20above%20workarounds%20until%20the%20remaining%20plugins%20are%20updated.%20If%20you%20encounter%20specific%20type%20errors%2C%20sharing%20the%20exact%20error%20messages%20can%20help%20track%20progress%20or%20suggest%20more%20targeted%20workarounds.)&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/6491)
Author
Owner

@ping-maxwell commented on GitHub (Dec 3, 2025):

Looking into it!

<!-- gh-comment-id:3608524902 --> @ping-maxwell commented on GitHub (Dec 3, 2025): Looking into it!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#10533