Organization plugin gives type error:
I get the following type-error when adding the organization plugin to my better-auth server client.
19 Replies
same error
hey @Nextify. pull request already open - https://github.com/better-auth/better-auth/pull/3084.
waiting for merge->release.
Till than, you can patch fix this issue.
Thank you very much for your response. Do you have plans to merge it into the next version?
I had the same problem, I solved it this way, apparently it's just a problem with typing, not with functionality:
organization({
allowUserToCreateOrganization: true,
teams: {
enabled: true,
},
ac,
roles: organizationRoles,
}) as import('better-auth').BetterAuthPlugin, // Type assertion
is it merged ? i still have that issue too
Hey can I see your tsconfig?
i used what said Gabirel and works fine, but sure i can show you my tsconfig file :
I really don't recommend following that advice since it means you lose ts inference for all of the organization endpoints.
Try disabling
declaration
and declarationMap
I tried following the docs to add the Organization pluging today and get the following typescript error;
This is without passing anything into the function, so no options. I'm using the drizzle adapter if that is related
For context

My previous thread, with package.json and tsconfig settings
https://discord.com/channels/1288403910284935179/1397295965169389691
@HotBBQSauce @tim7463 fyi
hey, is anyone able to make a minimal repro?
cc @tim7463 @DiamondDragon
Not to hand, just tried a fresh install with pg and drizzle and it works fine. The above was with D1 via the drizzle adapter so maybe its specific to that setup
I went to replicate this and the cause is the fact I've got
"exactOptionalPropertyTypes": true
set in my tsconfig, if you remove this option then the issue is resolved@Ping this isn't very minimal but should show the issue https://github.com/austinm911/zero-effect-better-t/blob/main/packages/backend/src/lib/auth.ts
template is wip so lmk if you have any issues
GitHub
zero-effect-better-t/packages/backend/src/lib/auth.ts at main · au...
Contribute to austinm911/zero-effect-better-t development by creating an account on GitHub.
We are seeing this as well. Happy to share tsconfig, package.json, or anything else that might be helpful.

Is there a github issue tracking already? I wasn't able to find one
FWIW this worked for us as well to at least get rid of that error, but unclear if it's killing type inference for all the organization endpoints now
Based on the example project my guess is it doesn’t support this compiler option although it was shipped in Ts 4.4 so it’s not new.
I doubt it breaks anything as that option is just extended strictness about a property being defined as undefined vs not being defined at all.
I assume I’ve got it on as the opennext cloudflare template must set it or it was required by arktype
Yeah removing it should be ok. I still can't get type inference for the organization imports but potentially a different issue
The example in the better auth repo was where I started and helped with the last issue