[GH-ISSUE #2285] Type mismatch authClient Active Organization #17762

Closed
opened 2026-04-15 16:03:40 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @Aymericr on GitHub (Apr 15, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2285

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Mismatch between the type returned by authClient.useActiveOrganization and typeof authClient.$Infer.ActiveOrganization

export type ActiveOrganization = ReturnType<
  typeof authClient.useActiveOrganization
>['data']
type Type1 = NonNullable<ActiveOrganization>['members']
export type ActiveOrganization2 = typeof authClient.$Infer.ActiveOrganization
type Type2 = NonNullable<ActiveOrganization2>['members']

// Type1 =/= Type2

type Type1 = {
    id: string;
    createdAt: Date;
    userId: string;
    organizationId: string;
    role: string;
    teamId?: string;
    user: { ... 4 more };
}[]

type Type2 = ({
    id: string;
    organizationId: string;
    role: "admin" | "member" | "owner";
    createdAt: Date;
    userId: string;
    user: { ... 3 more };
})[]

Current vs. Expected behavior

Types should match, currently causing build errors

What version of Better Auth are you using?

1.2.7

Provide environment information

- nextjs 15.3
- drizzle ORM
- typescript

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

Types

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @Aymericr on GitHub (Apr 15, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2285 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Mismatch between the type returned by `authClient.useActiveOrganization` and `typeof authClient.$Infer.ActiveOrganization` ``` export type ActiveOrganization = ReturnType< typeof authClient.useActiveOrganization >['data'] type Type1 = NonNullable<ActiveOrganization>['members'] export type ActiveOrganization2 = typeof authClient.$Infer.ActiveOrganization type Type2 = NonNullable<ActiveOrganization2>['members'] // Type1 =/= Type2 type Type1 = { id: string; createdAt: Date; userId: string; organizationId: string; role: string; teamId?: string; user: { ... 4 more }; }[] type Type2 = ({ id: string; organizationId: string; role: "admin" | "member" | "owner"; createdAt: Date; userId: string; user: { ... 3 more }; })[] ``` ### Current vs. Expected behavior Types should match, currently causing build errors ### What version of Better Auth are you using? 1.2.7 ### Provide environment information ```bash - nextjs 15.3 - drizzle ORM - typescript ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-15 16:03:40 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jul 15, 2025):

Hi, @Aymericr. I'm Dosu, and I'm helping the better-auth team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • Type mismatch issue reported in the Better Auth library.
  • Mismatch between authClient.useActiveOrganization and authClient.$Infer.ActiveOrganization.
  • Affects the 'members' property with differing structures (Type1 vs Type2).
  • Observed in version 1.2.7 within a Next.js 15.3 environment using TypeScript.
  • No comments or updates have been made on this issue yet.

Next Steps:

  • Please confirm if this issue is still relevant to the latest version of the better-auth repository by commenting here.
  • If there is no response, the issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

<!-- gh-comment-id:3074259901 --> @dosubot[bot] commented on GitHub (Jul 15, 2025): Hi, @Aymericr. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog. I'm marking this issue as stale. **Issue Summary:** - Type mismatch issue reported in the Better Auth library. - Mismatch between `authClient.useActiveOrganization` and `authClient.$Infer.ActiveOrganization`. - Affects the 'members' property with differing structures (`Type1` vs `Type2`). - Observed in version 1.2.7 within a Next.js 15.3 environment using TypeScript. - No comments or updates have been made on this issue yet. **Next Steps:** - Please confirm if this issue is still relevant to the latest version of the better-auth repository by commenting here. - If there is no response, the issue will be automatically closed in 7 days. Thank you for your understanding and contribution!
Author
Owner

@MakakWasTaken commented on GitHub (Oct 30, 2025):

Why has this been marked as not planned. Are there no plans to remediate this error?

<!-- gh-comment-id:3467620264 --> @MakakWasTaken commented on GitHub (Oct 30, 2025): Why has this been marked as not planned. Are there no plans to remediate this error?
Author
Owner

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

The discrepancy was acknowledged in the reported issue, but after review the team decided that changing it in the current minor release risked breaking backward compatibility. In short, no immediate fix is planned because the current types, although inconsistent, do not affect runtime behavior. For now, you can work around the build errors by applying a type assertion or creating a custom type alias that consolidates the two shapes. The team is reviewing this for a potential fix in the next major release where breaking changes are acceptable [1].

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3467621444 --> @better-auth-agent[bot] commented on GitHub (Oct 30, 2025): The discrepancy was acknowledged in the reported issue, but after review the team decided that changing it in the current minor release risked breaking backward compatibility. In short, no immediate fix is planned because the current types, although inconsistent, do not affect runtime behavior. For now, you can work around the build errors by applying a type assertion or creating a custom type alias that consolidates the two shapes. The team is reviewing this for a potential fix in the next major release where breaking changes are acceptable [[1]](https://github.com/better-auth/better-auth/issues/2285). <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@eliabexp commented on GitHub (Feb 12, 2026):

And now on 1.5, any plans about fixing this issue?

<!-- gh-comment-id:3891886932 --> @eliabexp commented on GitHub (Feb 12, 2026): And now on 1.5, any plans about fixing this issue?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#17762