-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Version 1.3.31 and v1.4.0-beta.13 type inference error requiring reference to better-call and breaking organization plugin #5574
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workinglockedLocked conversations after being closed for 7 daysLocked conversations after being closed for 7 days
Description
Is this suited for github?
- Yes, this is suited for github
To Reproduce
Upgrade to version 1.3.31 or v1.4.0-beta.13 and you will see type inference errors like this:
The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed. (ts 7056)
The inferred type of 'IamProvider' cannot be named without a reference to '.pnpm/better-call@1.0.24/node_modules/better-call'. This is likely not portable. A type annotation is necessary. (ts 2742)
By adding organization({}) you will get the following error, which is weird, as its keys are all optional and it still errors out with type incompatibility...
Current vs. Expected behavior
Current:
Type inference error no. 1 that requires a ref to better-call:
The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed. (ts 7056)
The inferred type of 'IamProvider' cannot be named without a reference to '.pnpm/better-call@1.0.24/node_modules/better-call'. This is likely not portable. A type annotation is necessary. (ts 2742)
Type inference error no. 2 that makes organization plugin totally incompatible:
Type '{ id: "organization"; endpoints: OrganizationEndpoints<{}>; schema: { organization: { modelName: string | undefined; fields: { name: { type: "string"; required: true; sortable: true; fieldName?: string | undefined; }; slug: { ...; }; logo: { ...; }; createdAt: { ...; }; updatedAt: { ...; }; }; }; member: { ...; }; i...' is not assignable to type 'BetterAuthPlugin'.
Types of property 'schema' are incompatible.
Type '{ organization: { modelName: string | undefined; fields: { name: { type: "string"; required: true; sortable: true; fieldName?: string | undefined; }; slug: { type: "string"; required: true; unique: true; sortable: true; fieldName?: string | undefined; }; logo: { ...; }; createdAt: { ...; }; updatedAt: { ...; }; }; }...' is not assignable to type 'BetterAuthPluginDBSchema'.
Property 'organization' is incompatible with index signature.
Type '{ modelName: string | undefined; fields: { name: { type: "string"; required: true; sortable: true; fieldName?: string | undefined; }; slug: { type: "string"; required: true; unique: true; sortable: true; fieldName?: string | undefined; }; logo: { ...; }; createdAt: { ...; }; updatedAt: { ...; }; }; }' is not assignable to type '{ fields: { [x: string]: DBFieldAttribute<DBFieldType>; }; disableMigration?: boolean; modelName?: string; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Types of property 'fields' are incompatible.
Type '{ name: { type: "string"; required: true; sortable: true; fieldName?: string | undefined; }; slug: { type: "string"; required: true; unique: true; sortable: true; fieldName?: string | undefined; }; logo: { ...; }; createdAt: { ...; }; updatedAt: { ...; }; }' is not assignable to type '{ [x: string]: DBFieldAttribute<DBFieldType>; }'.
Property 'name' is incompatible with index signature.
Type '{ type: "string"; required: true; sortable: true; fieldName?: string | undefined; }' is not assignable to type 'DBFieldAttribute<DBFieldType>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Type '{ type: "string"; required: true; sortable: true; fieldName?: string | undefined; }' is not assignable to type 'DBFieldAttributeConfig' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Types of property 'fieldName' are incompatible.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'. (ts 2322)
Expected:
None of this shows up and type inference works correctly.
What version of Better Auth are you using?
1.3.31 and v1.4.0-beta.13
System info
.Which area(s) are affected? (Select all that apply)
Package, Backend
Auth config (if applicable)
import { betterAuth } from "better-auth"
export const auth = betterAuth({
emailAndPassword: {
enabled: true
},
// Other configs...
plugins: [
organization({
}),
]
});Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinglockedLocked conversations after being closed for 7 daysLocked conversations after being closed for 7 days