Skip to content

Commit 696bd7c

Browse files
committed
fix(types): Update MembershipRole and OrganizationPermissionKey to not resolve to any
1 parent 1c96a9f commit 696bd7c

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

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

9896
export type UpdateOrganizationMembershipParams = {

0 commit comments

Comments
 (0)