Skip to content

Commit c86d688

Browse files
committed
fix(types): Update MembershipRole and OrganizationPermissionKey to not resolve to any
1 parent 70bbca7 commit c86d688

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

packages/types/src/organizationMembership.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,10 @@ export type OrganizationCustomRoleKey = ClerkAuthorization extends Placeholder
6868
* MembershipRole includes `admin`, `basic_member`, `guest_member`. With the introduction of "Custom roles"
6969
* these types will no longer match a developer's custom logic.
7070
*/
71-
export type MembershipRole = 'role' extends keyof ClerkAuthorization
72-
? // @ts-ignore Typescript cannot infer the existence of the `role` key even if we checking it above
73-
// Disabling eslint rule because the error causes the type to become any when accessing a property that does not exist
74-
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
75-
ClerkAuthorization['role'] | 'admin' | 'basic_member' | 'guest_member'
71+
export type MembershipRole = ClerkAuthorization extends Placeholder
72+
? ClerkAuthorization['role'] extends string
73+
? ClerkAuthorization['role'] | 'admin' | 'basic_member' | 'guest_member'
74+
: Autocomplete<'admin' | 'basic_member' | 'guest_member'>
7675
: Autocomplete<'admin' | 'basic_member' | 'guest_member'>;
7776

7877
export type OrganizationSystemPermissionKey =
@@ -87,11 +86,10 @@ export type OrganizationSystemPermissionKey =
8786
* OrganizationPermissionKey is a combination of system and custom permissions.
8887
* System permissions are only accessible from FAPI and client-side operations/utils
8988
*/
90-
export type OrganizationPermissionKey = 'permission' extends keyof ClerkAuthorization
91-
? // @ts-ignore Typescript cannot infer the existence of the `permission` key even if we checking it above
92-
// Disabling eslint rule because the error causes the type to become any when accessing a property that does not exist
93-
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
94-
ClerkAuthorization['permission'] | OrganizationSystemPermissionKey
89+
export type OrganizationPermissionKey = ClerkAuthorization extends Placeholder
90+
? ClerkAuthorization['permission'] extends string
91+
? ClerkAuthorization['permission'] | OrganizationSystemPermissionKey
92+
: Autocomplete<OrganizationSystemPermissionKey>
9593
: Autocomplete<OrganizationSystemPermissionKey>;
9694

9795
export type UpdateOrganizationMembershipParams = {

0 commit comments

Comments
 (0)