[PR #4612] [MERGED] fix: should infer types correctly when empty list of plugins is provided #22383

Closed
opened 2026-04-15 21:00:33 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4612
Author: @frectonz
Created: 9/12/2025
Status: Merged
Merged: 9/12/2025
Merged by: @Bekacru

Base: canaryHead: fix/infer-empty-plugins


📝 Commits (2)

  • 0332cd8 fix: infer types for empty list plugins correctly
  • cc485b5 fix: cast instance opts as unknown

📊 Changes

5 files changed (+39 additions, -15 deletions)

View changed files

📝 packages/better-auth/src/db/field.ts (+14 -12)
📝 packages/better-auth/src/test-utils/index.ts (+1 -1)
📝 packages/better-auth/src/test-utils/test-instance.ts (+1 -1)
📝 packages/better-auth/src/types/options.ts (+1 -1)
📝 packages/better-auth/src/types/types.test.ts (+22 -0)

📄 Description

Make sure the following infer the same types.

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

and

const auth = betterAuth({
});

Summary by cubic

Ensure betterAuth({ plugins: [] }) infers the same types as betterAuth({}). This removes inconsistent $Infer results when the plugins array is empty.

  • Bug Fixes
    • Return {} from InferFieldsFromPlugins when plugins is [].
    • Narrow BetterAuthOptions.plugins to [] | BetterAuthPlugin[] to preserve empty-array literal.
    • Add a type test to confirm both configurations produce equal types.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/4612 **Author:** [@frectonz](https://github.com/frectonz) **Created:** 9/12/2025 **Status:** ✅ Merged **Merged:** 9/12/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/infer-empty-plugins` --- ### 📝 Commits (2) - [`0332cd8`](https://github.com/better-auth/better-auth/commit/0332cd826c8f22f9862dfe9793dc4827736c153d) fix: infer types for empty list plugins correctly - [`cc485b5`](https://github.com/better-auth/better-auth/commit/cc485b5c0ee65efda9b00f2722bd421c2136d13d) fix: cast instance opts as unknown ### 📊 Changes **5 files changed** (+39 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/db/field.ts` (+14 -12) 📝 `packages/better-auth/src/test-utils/index.ts` (+1 -1) 📝 `packages/better-auth/src/test-utils/test-instance.ts` (+1 -1) 📝 `packages/better-auth/src/types/options.ts` (+1 -1) 📝 `packages/better-auth/src/types/types.test.ts` (+22 -0) </details> ### 📄 Description Make sure the following infer the same types. ```typescript const auth = betterAuth({ plugins: [] }); ``` and ```typescript const auth = betterAuth({ }); ``` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Ensure betterAuth({ plugins: [] }) infers the same types as betterAuth({}). This removes inconsistent $Infer results when the plugins array is empty. - **Bug Fixes** - Return {} from InferFieldsFromPlugins when plugins is []. - Narrow BetterAuthOptions.plugins to [] | BetterAuthPlugin[] to preserve empty-array literal. - Add a type test to confirm both configurations produce equal types. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 21:00:33 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#22383