-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Issues with exactOptionalPropertyTypes when using server API from organization plugin #4804
Copy link
Copy link
Closed
Labels
lockedLocked 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
auth.api.createOrgRole({
body: {
role: payload.roleName,
permission: payload.permission,
organizationId: payload.organizationId // <------- Doesnt accept: organizationId: string | undefined
},
headers: fromNodeHeaders(req.headers),
}),auth.api.updateOrgRole({
body: {
roleId: payload.roleId,
roleName: payload.roleName,
data: {
roleName: payload.roleName,
permission : payload.permission // <------- Doesnt accept: permission: { [x: string]: string[]; } | undefined
}
},
headers: fromNodeHeaders(req.headers),
}),auth.api.deleteOrgRole({
body: {
roleId: payload.roleId,
roleName: payload.roleName,
organizationId: payload.organizationId // <------- Doesnt accept: organizationId: string | undefined
},
headers: fromNodeHeaders(req.headers),
}),Current vs. Expected behavior
Current: Doesn't accept value of type string | undefined.
Expected: all methods where this a type defined as smth?: Sometype, it should accept Sometype | undefined. Otherwise exactOptionalPropertyTypes throw an error.
✅ This API should be the target as it has every type and property properly defined. => auth.api.createOrganization()
What version of Better Auth are you using?
1.3.13
System info
.Which area(s) are affected? (Select all that apply)
Backend
Auth config (if applicable)
Additional context
Error example
Type '{ role: string; permission: { [x: string]: string[]; }; organizationId: string | undefined; }' is not assignable to type '{ organizationId?: string; role: string; permission: Record<string, string[]>; } & { additionalFields?: {}; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Type '{ role: string; permission: { [x: string]: string[]; }; organizationId: string | undefined; }' is not assignable to type '{ organizationId?: string; role: string; permission: Record<string, string[]>; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Types of property 'organizationId' are incompatible.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'. (ts 2375)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
lockedLocked conversations after being closed for 7 daysLocked conversations after being closed for 7 days