Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/tame-olives-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
19 changes: 13 additions & 6 deletions packages/types/src/organizationMembership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ interface Base {
role: string;
}

interface Placeholder {
permission: unknown;
role: unknown;
}

declare global {
interface ClerkAuthorization {}
}
Expand Down Expand Up @@ -45,14 +50,16 @@ export interface OrganizationMembershipResource extends ClerkResource {
update: (updateParams: UpdateOrganizationMembershipParams) => Promise<OrganizationMembershipResource>;
}

export type OrganizationCustomPermissionKey = 'permission' extends keyof ClerkAuthorization
? // @ts-ignore Typescript cannot infer the existence of the `permission` key even if we checking it above
ClerkAuthorization['permission']
export type OrganizationCustomPermissionKey = ClerkAuthorization extends Placeholder
? ClerkAuthorization['permission'] extends string
? ClerkAuthorization['permission']
: Base['permission']
: Base['permission'];

export type OrganizationCustomRoleKey = 'role' extends keyof ClerkAuthorization
? // @ts-ignore Typescript cannot infer the existence of the `role` key even if we checking it above
ClerkAuthorization['role']
export type OrganizationCustomRoleKey = ClerkAuthorization extends Placeholder
? ClerkAuthorization['role'] extends string
? ClerkAuthorization['role']
: Base['role']
: Base['role'];

/**
Expand Down