Skip to content

Commit

Permalink
chore(clerk-react): Stricter types for custom pages (#2939)
Browse files Browse the repository at this point in the history
  • Loading branch information
panteliselef authored Mar 5, 2024
1 parent afd221e commit c86f73b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/rotten-ligers-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-react': patch
---

Introducing stricter types for custom pages for UserProfile and OrganizationProfile.
21 changes: 15 additions & 6 deletions packages/react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type ButtonProps = {
};

export type SignInButtonProps = ButtonProps;

export interface SignUpButtonProps extends ButtonProps {
unsafeMetadata?: SignUpUnsafeMetadata;
}
Expand All @@ -91,17 +92,25 @@ export type SignInWithMetamaskButtonProps = Pick<ButtonProps, 'redirectUrl' | 'c
export type RedirectToSignInProps = SignInRedirectOptions;
export type RedirectToSignUpProps = SignUpRedirectOptions;

export type UserProfilePageProps = {
url?: string;
label: string;
labelIcon?: React.ReactNode;
};
type PageProps<T extends string> =
| {
label: string;
url: string;
labelIcon: React.ReactNode;
}
| {
label: T;
url?: never;
labelIcon?: never;
};

export type UserProfilePageProps = PageProps<'account' | 'security'>;

export type UserProfileLinkProps = {
url: string;
label: string;
labelIcon: React.ReactNode;
};

export type OrganizationProfilePageProps = UserProfilePageProps;
export type OrganizationProfilePageProps = PageProps<'general' | 'members'>;
export type OrganizationProfileLinkProps = UserProfileLinkProps;

0 comments on commit c86f73b

Please sign in to comment.