Typescript error in the better auth instance configuration when using organization()

The title explains most of it, here is the specific error message:
Type '{ id: "organization"; endpoints: { createOrganization: { <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0: { body: { name: string; slug: string; userId?: string | undefined; logo?: string | undefined; metadata?: Record<...> | undefined; keepCurrentActiveOrganization?: boolean | ...' is not assignable to type 'BetterAuthPlugin'.
Types of property 'schema' are incompatible.
Type '{ team?: { modelName: string | undefined; fields: { name: { type: "string"; required: true; fieldName: string | undefined; }; organizationId: { type: "string"; required: true; references: { model: string; field: string; }; fieldName: string | undefined; }; createdAt: { ...; }; updatedAt: { ...; }; }; } | undefined; ...' is not assignable to type 'AuthPluginSchema'.
Property 'team' is incompatible with index signature.
Type '{ modelName: string | undefined; fields: { name: { type: "string"; required: true; fieldName: string | undefined; }; organizationId: { type: "string"; required: true; references: { model: string; field: string; }; fieldName: string | undefined; }; createdAt: { ...; }; updatedAt: { ...; }; }; } | undefined' is not assignable to type '{ fields: { [x: string]: FieldAttribute<FieldType>; }; disableMigration?: boolean; modelName?: string; }'.
Type 'undefined' is not assignable to type '{ fields: { [x: string]: FieldAttribute<FieldType>; }; disableMigration?: boolean; modelName?: string; }'.ts(2322)
Type '{ id: "organization"; endpoints: { createOrganization: { <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0: { body: { name: string; slug: string; userId?: string | undefined; logo?: string | undefined; metadata?: Record<...> | undefined; keepCurrentActiveOrganization?: boolean | ...' is not assignable to type 'BetterAuthPlugin'.
Types of property 'schema' are incompatible.
Type '{ team?: { modelName: string | undefined; fields: { name: { type: "string"; required: true; fieldName: string | undefined; }; organizationId: { type: "string"; required: true; references: { model: string; field: string; }; fieldName: string | undefined; }; createdAt: { ...; }; updatedAt: { ...; }; }; } | undefined; ...' is not assignable to type 'AuthPluginSchema'.
Property 'team' is incompatible with index signature.
Type '{ modelName: string | undefined; fields: { name: { type: "string"; required: true; fieldName: string | undefined; }; organizationId: { type: "string"; required: true; references: { model: string; field: string; }; fieldName: string | undefined; }; createdAt: { ...; }; updatedAt: { ...; }; }; } | undefined' is not assignable to type '{ fields: { [x: string]: FieldAttribute<FieldType>; }; disableMigration?: boolean; modelName?: string; }'.
Type 'undefined' is not assignable to type '{ fields: { [x: string]: FieldAttribute<FieldType>; }; disableMigration?: boolean; modelName?: string; }'.ts(2322)
5 Replies
HotBBQSauce
HotBBQSauceOP2mo ago
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
}),
emailAndPassword: {
enabled: true,
requireEmailVerification: true,
},
socialProviders: {
github: {
clientId: GITHUB_CLIENT_ID,
clientSecret: GITHUB_CLIENT_SECRET,
},
},
plugins: [
username(),
passkey(),
admin(),
multiSession(),
organization({
allowUserToCreateOrganization: true,
}),
oidcProvider({
loginPage: "/login",
}),
genericOAuth({
config: [],
}),
],
});
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
}),
emailAndPassword: {
enabled: true,
requireEmailVerification: true,
},
socialProviders: {
github: {
clientId: GITHUB_CLIENT_ID,
clientSecret: GITHUB_CLIENT_SECRET,
},
},
plugins: [
username(),
passkey(),
admin(),
multiSession(),
organization({
allowUserToCreateOrganization: true,
}),
oidcProvider({
loginPage: "/login",
}),
genericOAuth({
config: [],
}),
],
});
I've followed the docs step by step, this is not the first time setting up organizations, it never complained with this typecript error, this might be due to me being on the latest typescript 5.9 beta, and a node version 24.4.1
HotBBQSauce
HotBBQSauceOP2mo ago
Below is the schema, this is automatically generated.
HotBBQSauce
HotBBQSauceOP2mo ago
there is also a build error:
src/auth.ts:41:9 - error TS2322: Type '{ id: "organization"; endpoints: { createOrganization: { <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0: { body: { name: string; slug: string; userId?: string | undefined; logo?: string | undefined; metadata?: Record<...> | undefined; keepCurrentActiveOrganization?: boolean | ...' is not assignable to type 'BetterAuthPlugin'.
Types of property 'schema' are incompatible.
Type '{ team?: { modelName: string | undefined; fields: { name: { type: "string"; required: true; fieldName: string | undefined; }; organizationId: { type: "string"; required: true; references: { model: string; field: string; }; fieldName: string | undefined; }; createdAt: { ...; }; updatedAt: { ...; }; }; } | undefined; ...' is not assignable to type 'AuthPluginSchema'.
Property 'team' is incompatible with index signature.
Type '{ modelName: string | undefined; fields: { name: { type: "string"; required: true; fieldName: string | undefined; }; organizationId: { type: "string"; required: true; references: { model: string; field: string; }; fieldName: string | undefined; }; createdAt: { ...; }; updatedAt: { ...; }; }; } | undefined' is not assignable to type '{ fields: { [x: string]: FieldAttribute<FieldType>; }; disableMigration?: boolean; modelName?: string; }'.
Type 'undefined' is not assignable to type '{ fields: { [x: string]: FieldAttribute<FieldType>; }; disableMigration?: boolean; modelName?: string; }'.

41 organization({
~~~~~~~~~~~~~~
42 allowUserToCreateOrganization: true,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43 }),
src/auth.ts:41:9 - error TS2322: Type '{ id: "organization"; endpoints: { createOrganization: { <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0: { body: { name: string; slug: string; userId?: string | undefined; logo?: string | undefined; metadata?: Record<...> | undefined; keepCurrentActiveOrganization?: boolean | ...' is not assignable to type 'BetterAuthPlugin'.
Types of property 'schema' are incompatible.
Type '{ team?: { modelName: string | undefined; fields: { name: { type: "string"; required: true; fieldName: string | undefined; }; organizationId: { type: "string"; required: true; references: { model: string; field: string; }; fieldName: string | undefined; }; createdAt: { ...; }; updatedAt: { ...; }; }; } | undefined; ...' is not assignable to type 'AuthPluginSchema'.
Property 'team' is incompatible with index signature.
Type '{ modelName: string | undefined; fields: { name: { type: "string"; required: true; fieldName: string | undefined; }; organizationId: { type: "string"; required: true; references: { model: string; field: string; }; fieldName: string | undefined; }; createdAt: { ...; }; updatedAt: { ...; }; }; } | undefined' is not assignable to type '{ fields: { [x: string]: FieldAttribute<FieldType>; }; disableMigration?: boolean; modelName?: string; }'.
Type 'undefined' is not assignable to type '{ fields: { [x: string]: FieldAttribute<FieldType>; }; disableMigration?: boolean; modelName?: string; }'.

41 organization({
~~~~~~~~~~~~~~
42 allowUserToCreateOrganization: true,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43 }),
should i open an issue on the github repository?
hegillis
hegillis2mo ago
Did you have any luck with this one?
luksch42
luksch422mo ago
Any update?

Did you find this page helpful?