[PR #3941] [MERGED] fix(org): make plugin schema compatible with exactOptionalPropertyTypes #30700

Closed
opened 2026-04-17 21:43:55 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3941
Author: @Kinfe123
Created: 8/12/2025
Status: Merged
Merged: 8/13/2025
Merged by: @Bekacru

Base: canaryHead: fix/organization-exact-optional-schema


📝 Commits (7)

  • 9999035 fix(organization): make plugin schema compatible with exactOptionalPropertyTypes; build schema object without undefined optional keys and merge team tables conditionally; keep session fields literal and add teams conditionally
  • ec73120 fix(org): make plugin schema compatible with exactOptionalPropertyTypes
  • 5be3252 clean up
  • 26337cf update
  • a9116b8 update
  • a7813bc typecheck
  • 959e70f update

📊 Changes

1 file changed (+137 additions, -132 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/organization.ts (+137 -132)

📄 Description

With ts's exactOptionalPropertyTypes enabled, the org plugin was returning a schema object whose keys (e.g., team, teamMember) were sometimes present with undefined values due to conditional construction. This violates the AuthPluginSchema index signature because undefined is not assignable to the table shape, causing the “Property 'team' is incompatible with index signature” error.

Summary by cubic

Updated the organization plugin schema to avoid undefined optional keys and ensure compatibility with TypeScript's exactOptionalPropertyTypes setting.

  • Refactors
  • Built schema objects without spreading undefined values.
  • Merged team tables and session fields only when team support is enabled.

🔄 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/3941 **Author:** [@Kinfe123](https://github.com/Kinfe123) **Created:** 8/12/2025 **Status:** ✅ Merged **Merged:** 8/13/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/organization-exact-optional-schema` --- ### 📝 Commits (7) - [`9999035`](https://github.com/better-auth/better-auth/commit/9999035645037844bd2b2aa55a250460bd8a3289) fix(organization): make plugin schema compatible with exactOptionalPropertyTypes; build schema object without undefined optional keys and merge team tables conditionally; keep session fields literal and add teams conditionally - [`ec73120`](https://github.com/better-auth/better-auth/commit/ec7312067b4173b2e830ad218d825a3d59570bce) fix(org): make plugin schema compatible with exactOptionalPropertyTypes - [`5be3252`](https://github.com/better-auth/better-auth/commit/5be325244d86f3b9bcda97f57d980c5a954dfd12) clean up - [`26337cf`](https://github.com/better-auth/better-auth/commit/26337cf36ad046efbaa70eb5abb32b81cd8309f2) update - [`a9116b8`](https://github.com/better-auth/better-auth/commit/a9116b800c0f19ed764992a2fc77231736293936) update - [`a7813bc`](https://github.com/better-auth/better-auth/commit/a7813bcdd1c1c8e28bc5f34bd7dbade4b5ed2857) typecheck - [`959e70f`](https://github.com/better-auth/better-auth/commit/959e70f553dc3f07fa2a66842f7bea185db05abc) update ### 📊 Changes **1 file changed** (+137 additions, -132 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/organization.ts` (+137 -132) </details> ### 📄 Description With ts's exactOptionalPropertyTypes enabled, the org plugin was returning a schema object whose keys (e.g., team, teamMember) were sometimes present with undefined values due to conditional construction. This violates the AuthPluginSchema index signature because undefined is not assignable to the table shape, causing the “Property 'team' is incompatible with index signature” error. <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Updated the organization plugin schema to avoid undefined optional keys and ensure compatibility with TypeScript's exactOptionalPropertyTypes setting. - **Refactors** - Built schema objects without spreading undefined values. - Merged team tables and session fields only when team support is enabled. <!-- 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-17 21:43:55 -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#30700