[PR #5537] [CLOSED] fix(organization): missing or inconsistent types #22971

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5537
Author: @feychenie
Created: 10/24/2025
Status: Closed

Base: mainHead: orgs-ts-fixes


📝 Commits (10+)

📊 Changes

642 files changed (+37573 additions, -9843 deletions)

View changed files

.github/workflows/branch-rules.yml (+0 -36)
📝 .github/workflows/ci.yml (+2 -2)
📝 .github/workflows/e2e.yml (+6 -5)
.github/workflows/main-protect.yml (+0 -18)
📝 .github/workflows/preview.yml (+2 -2)
📝 .github/workflows/release.yml (+11 -6)
📝 CONTRIBUTING.md (+30 -6)
📝 README.md (+1 -1)
📝 biome.json (+4 -2)
demo/expo-example/.env.example (+7 -0)
demo/expo-example/.gitignore (+20 -0)
demo/expo-example/README.md (+15 -0)
demo/expo-example/app.config.ts (+55 -0)
demo/expo-example/assets/bg-image.jpeg (+0 -0)
demo/expo-example/assets/fonts/SpaceMono-Regular.ttf (+0 -0)
demo/expo-example/assets/icon.png (+0 -0)
demo/expo-example/assets/images/adaptive-icon.png (+0 -0)
demo/expo-example/assets/images/favicon.png (+0 -0)
demo/expo-example/assets/images/logo.png (+0 -0)
demo/expo-example/assets/images/partial-react-logo.png (+0 -0)

...and 80 more files

📄 Description

Fix some missing or inconsistent types on organization plugin

This PR only improves some type declarations and does not touch any logic.

1. On the organization plugin, some dynamic options params are missing the & Record<string, any> that are used on all other dynamic options.

example:

allowUserToCreateOrganization?:
		| boolean
		| ((user: User & Record<string, any>) => Promise<boolean> | boolean);

organizationLimit?: number | ((user: User) => Promise<boolean> | boolean);
//                                      ^ missing & Record<string, any>

2. On the client plugin, the schema typing is incompatible with inferOrgAdditionalFields when the server plugin schema has modelName or fields declarations (without additionalFields).

example, with this config:

organization({
  schema: {
    organization: {
      fields: {
        metadata: 'meta',
      },
    },
})

the schema property on the organizationsClient plugin with have this error:

organizationClient({
  schema: inferOrgAdditionaFields<typeof auth>()
})

Types of property 'organization' are incompatible.
    Type '{ fields: { metadata: string; }; }' has no properties in common with type '{ additionalFields?: { [key: string]: DBFieldAttribute; } | undefined; }'.

Summary by cubic

Fix inconsistent types in the organization plugin and client schema to remove TypeScript errors and align with server-side schema options. No logic changes.

  • Bug Fixes
    • Added Record<string, any> to user/session/organization/member/invitation types across dynamic option callbacks (e.g., organizationLimit, invitation hooks, delete hooks, team limits).
    • Extended organizationsClient schema typing to support modelName and fields for organization, member, invitation, team, organizationRole, and session fields, making it compatible with inferOrgAdditionalFields.

Written for commit 90a403159d. Summary will update automatically on new commits.


🔄 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/5537 **Author:** [@feychenie](https://github.com/feychenie) **Created:** 10/24/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `orgs-ts-fixes` --- ### 📝 Commits (10+) - [`d52cbab`](https://github.com/better-auth/better-auth/commit/d52cbab069b62396c8e6640b4703d7a8b7f4ff66) chore: release v1.3.20 - [`0f5ccce`](https://github.com/better-auth/better-auth/commit/0f5ccce4cc45fa6ddb630521777605f3fe317d7a) chore: release v1.3.22 - [`fbde661`](https://github.com/better-auth/better-auth/commit/fbde661f44e878e218ddc0721b76cc63b3888024) chore: remove log - [`565fe8e`](https://github.com/better-auth/better-auth/commit/565fe8e37e95405fbc48bab1a56a01973a240770) chore: release v1.3.23 - [`8243189`](https://github.com/better-auth/better-auth/commit/82431899dc5bcdb95a9c0d624505dc0b2f43e8be) chore: typecheck using monorepo (#4920) - [`44d3f4e`](https://github.com/better-auth/better-auth/commit/44d3f4e7c801a2c418832fbe439a110c9fd4b530) refactor: move db schema to core (#4918) - [`9664b9a`](https://github.com/better-auth/better-auth/commit/9664b9a834a26f9735cc99bb6adf4f7e4751bd0f) feat: waku integration guide (#3990) - [`2852122`](https://github.com/better-auth/better-auth/commit/28521222bf7e2bc99051e87b5cfd13fc6a48fbbd) refactor: move mockLogger into the specific test file (#4931) - [`458cb20`](https://github.com/better-auth/better-auth/commit/458cb207ccf4836e17f9578a138f05bd2ff6b303) feat: add support for custom callback for authorization url (#4919) - [`574b962`](https://github.com/better-auth/better-auth/commit/574b9624f0a00dd8373f11182f0c78a6f408f71a) perf: improve type `Auth` (#4930) ### 📊 Changes **642 files changed** (+37573 additions, -9843 deletions) <details> <summary>View changed files</summary> ➖ `.github/workflows/branch-rules.yml` (+0 -36) 📝 `.github/workflows/ci.yml` (+2 -2) 📝 `.github/workflows/e2e.yml` (+6 -5) ➖ `.github/workflows/main-protect.yml` (+0 -18) 📝 `.github/workflows/preview.yml` (+2 -2) 📝 `.github/workflows/release.yml` (+11 -6) 📝 `CONTRIBUTING.md` (+30 -6) 📝 `README.md` (+1 -1) 📝 `biome.json` (+4 -2) ➕ `demo/expo-example/.env.example` (+7 -0) ➕ `demo/expo-example/.gitignore` (+20 -0) ➕ `demo/expo-example/README.md` (+15 -0) ➕ `demo/expo-example/app.config.ts` (+55 -0) ➕ `demo/expo-example/assets/bg-image.jpeg` (+0 -0) ➕ `demo/expo-example/assets/fonts/SpaceMono-Regular.ttf` (+0 -0) ➕ `demo/expo-example/assets/icon.png` (+0 -0) ➕ `demo/expo-example/assets/images/adaptive-icon.png` (+0 -0) ➕ `demo/expo-example/assets/images/favicon.png` (+0 -0) ➕ `demo/expo-example/assets/images/logo.png` (+0 -0) ➕ `demo/expo-example/assets/images/partial-react-logo.png` (+0 -0) _...and 80 more files_ </details> ### 📄 Description ## Fix some missing or inconsistent types on organization plugin This PR only improves some type declarations and does not touch any logic. ### 1. On the organization plugin, some dynamic options params are missing the `& Record<string, any>` that are used on all other dynamic options. example: ``` allowUserToCreateOrganization?: | boolean | ((user: User & Record<string, any>) => Promise<boolean> | boolean); organizationLimit?: number | ((user: User) => Promise<boolean> | boolean); // ^ missing & Record<string, any> ``` ### 2. On the client plugin, the `schema` typing is incompatible with `inferOrgAdditionalFields` when the server plugin schema has `modelName` or `fields` declarations (without `additionalFields`). example, with this config: ```ts organization({ schema: { organization: { fields: { metadata: 'meta', }, }, }) ``` the `schema` property on the `organizationsClient` plugin with have this error: ``` organizationClient({ schema: inferOrgAdditionaFields<typeof auth>() }) Types of property 'organization' are incompatible. Type '{ fields: { metadata: string; }; }' has no properties in common with type '{ additionalFields?: { [key: string]: DBFieldAttribute; } | undefined; }'. ``` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fix inconsistent types in the organization plugin and client schema to remove TypeScript errors and align with server-side schema options. No logic changes. - **Bug Fixes** - Added Record<string, any> to user/session/organization/member/invitation types across dynamic option callbacks (e.g., organizationLimit, invitation hooks, delete hooks, team limits). - Extended organizationsClient schema typing to support modelName and fields for organization, member, invitation, team, organizationRole, and session fields, making it compatible with inferOrgAdditionalFields. <sup>Written for commit 90a403159dc3b4a2e183140937c26b5fed8bcc2c. Summary will update automatically on new commits.</sup> <!-- 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:23:53 -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#22971