Skip to content

Commit 1345cb4

Browse files
alexcarpenterLekoArts
andauthoredJan 27, 2025··
refactor(clerk-js,types): Remove virtual routing option from component types (#4977)
Co-authored-by: Lennart <lekoarts@gmail.com>
1 parent 19a33eb commit 1345cb4

File tree

8 files changed

+46
-21
lines changed

8 files changed

+46
-21
lines changed
 

‎.changeset/silent-ducks-wait.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
'@clerk/types': patch
4+
---
5+
6+
Remove `'virtual'` from the `routing` option. The `'virtual'` value is only used internally and should not be part of the public API.

‎packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationProfile.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { useOrganization } from '@clerk/shared/react';
2-
import type { OrganizationProfileModalProps, OrganizationProfileProps } from '@clerk/types';
2+
import type { OrganizationProfileModalProps, OrganizationProfileProps, WithInternalRouting } from '@clerk/types';
33
import React from 'react';
4+
import type { OrganizationProfileCtx } from 'ui/types';
45

56
import { OrganizationProfileContext, withCoreUserGuard } from '../../contexts';
67
import { Flow, localizationKeys } from '../../customizables';
78
import { NavbarMenuButtonRow, ProfileCard, withCardStateProvider } from '../../elements';
89
import { Route, Switch } from '../../router';
9-
import type { OrganizationProfileCtx } from '../../types';
1010
import { OrganizationProfileNavbar } from './OrganizationProfileNavbar';
1111
import { OrganizationProfileRoutes } from './OrganizationProfileRoutes';
1212

13-
const _OrganizationProfile = (_: OrganizationProfileProps) => {
13+
const _OrganizationProfile = () => {
1414
const { organization } = useOrganization();
1515

1616
if (!organization) {
@@ -48,6 +48,9 @@ const AuthenticatedRoutes = withCoreUserGuard(() => {
4848

4949
export const OrganizationProfile = withCardStateProvider(_OrganizationProfile);
5050

51+
const InternalOrganizationProfile: React.ComponentType<WithInternalRouting<OrganizationProfileProps>> =
52+
withCardStateProvider(_OrganizationProfile);
53+
5154
export const OrganizationProfileModal = (props: OrganizationProfileModalProps): JSX.Element => {
5255
const organizationProfileProps: OrganizationProfileCtx = {
5356
...props,
@@ -61,7 +64,7 @@ export const OrganizationProfileModal = (props: OrganizationProfileModalProps):
6164
<OrganizationProfileContext.Provider value={organizationProfileProps}>
6265
{/*TODO: Used by InvisibleRootBox, can we simplify? */}
6366
<div>
64-
<OrganizationProfile {...organizationProfileProps} />
67+
<InternalOrganizationProfile {...organizationProfileProps} />
6568
</div>
6669
</OrganizationProfileContext.Provider>
6770
</Route>

‎packages/clerk-js/src/ui/components/SignIn/SignIn.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useClerk } from '@clerk/shared/react';
2-
import type { SignInModalProps, SignInProps } from '@clerk/types';
2+
import type { SignInModalProps, SignInProps, WithInternalRouting } from '@clerk/types';
33
import React from 'react';
44

55
import { normalizeRoutingOptions } from '../../../utils/normalizeRoutingOptions';
@@ -165,6 +165,8 @@ SignInRoutes.displayName = 'SignIn';
165165

166166
export const SignIn: React.ComponentType<SignInProps> = withCoreSessionSwitchGuard(SignInRoot);
167167

168+
const InternalSignIn: React.ComponentType<WithInternalRouting<SignInProps>> = withCoreSessionSwitchGuard(SignInRoot);
169+
168170
export const SignInModal = (props: SignInModalProps): JSX.Element => {
169171
const signInProps = {
170172
signUpUrl: `/${VIRTUAL_ROUTER_BASE_PATH}/sign-up`,
@@ -184,7 +186,7 @@ export const SignInModal = (props: SignInModalProps): JSX.Element => {
184186
>
185187
{/*TODO: Used by InvisibleRootBox, can we simplify? */}
186188
<div>
187-
<SignIn
189+
<InternalSignIn
188190
{...signInProps}
189191
routing='virtual'
190192
/>

‎packages/clerk-js/src/ui/components/SignUp/SignUp.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useClerk } from '@clerk/shared/react';
2-
import type { SignUpModalProps, SignUpProps } from '@clerk/types';
2+
import type { SignUpModalProps, SignUpProps, WithInternalRouting } from '@clerk/types';
33
import React from 'react';
44

55
import { SignUpEmailLinkFlowComplete } from '../../common/EmailLinkCompleteFlowCard';
@@ -89,6 +89,8 @@ SignUpRoutes.displayName = 'SignUp';
8989

9090
export const SignUp: React.ComponentType<SignUpProps> = withCoreSessionSwitchGuard(SignUpRoutes);
9191

92+
const InternalSignUp: React.ComponentType<WithInternalRouting<SignUpProps>> = withCoreSessionSwitchGuard(SignUpRoutes);
93+
9294
export const SignUpModal = (props: SignUpModalProps): JSX.Element => {
9395
const signUpProps = {
9496
signInUrl: `/${VIRTUAL_ROUTER_BASE_PATH}/sign-in`,
@@ -108,7 +110,7 @@ export const SignUpModal = (props: SignUpModalProps): JSX.Element => {
108110
>
109111
{/*TODO: Used by InvisibleRootBox, can we simplify? */}
110112
<div>
111-
<SignUp
113+
<InternalSignUp
112114
{...signUpProps}
113115
routing='virtual'
114116
/>

‎packages/clerk-js/src/ui/components/UserProfile/UserProfile.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { UserProfileModalProps, UserProfileProps } from '@clerk/types';
1+
import type { UserProfileModalProps, UserProfileProps, WithInternalRouting } from '@clerk/types';
22
import React from 'react';
33

44
import { UserProfileContext, withCoreUserGuard } from '../../contexts';
@@ -10,7 +10,7 @@ import { UserProfileNavbar } from './UserProfileNavbar';
1010
import { UserProfileRoutes } from './UserProfileRoutes';
1111
import { VerificationSuccessPage } from './VerifyWithLink';
1212

13-
const _UserProfile = (_: UserProfileProps) => {
13+
const _UserProfile = () => {
1414
return (
1515
<Flow.Root flow='userProfile'>
1616
<Flow.Part>
@@ -42,7 +42,10 @@ const AuthenticatedRoutes = withCoreUserGuard(() => {
4242
);
4343
});
4444

45-
export const UserProfile = withCardStateProvider(_UserProfile);
45+
export const UserProfile: React.ComponentType<UserProfileProps> = withCardStateProvider(_UserProfile);
46+
47+
const InternalUserProfile: React.ComponentType<WithInternalRouting<UserProfileProps>> =
48+
withCardStateProvider(_UserProfile);
4649

4750
export const UserProfileModal = (props: UserProfileModalProps): JSX.Element => {
4851
const userProfileProps: UserProfileCtx = {
@@ -57,7 +60,7 @@ export const UserProfileModal = (props: UserProfileModalProps): JSX.Element => {
5760
<UserProfileContext.Provider value={userProfileProps}>
5861
{/*TODO: Used by InvisibleRootBox, can we simplify? */}
5962
<div>
60-
<UserProfile {...userProfileProps} />
63+
<InternalUserProfile {...userProfileProps} />
6164
</div>
6265
</UserProfileContext.Provider>
6366
</Route>

‎packages/clerk-js/src/ui/components/UserVerification/index.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import type { __internal_UserVerificationModalProps, __internal_UserVerificationProps } from '@clerk/types';
1+
import type {
2+
__internal_UserVerificationModalProps,
3+
__internal_UserVerificationProps,
4+
WithInternalRouting,
5+
} from '@clerk/types';
26
import React, { useEffect } from 'react';
37

48
import { UserVerificationContext, withCoreSessionSwitchGuard } from '../../contexts';
@@ -31,7 +35,7 @@ function UserVerificationRoutes(): JSX.Element {
3135

3236
UserVerificationRoutes.displayName = 'UserVerification';
3337

34-
const UserVerification: React.ComponentType<__internal_UserVerificationProps> =
38+
const UserVerification: React.ComponentType<WithInternalRouting<__internal_UserVerificationProps>> =
3539
withCoreSessionSwitchGuard(UserVerificationRoutes);
3640

3741
const UserVerificationModal = (props: __internal_UserVerificationModalProps): JSX.Element => {

‎packages/clerk-js/src/ui/types.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type {
1010
UserButtonProps,
1111
UserProfileProps,
1212
WaitlistProps,
13+
WithInternalRouting,
1314
} from '@clerk/types';
1415

1516
export type {
@@ -40,22 +41,22 @@ export type AvailableComponentProps =
4041

4142
type ComponentMode = 'modal' | 'mounted';
4243

43-
export type SignInCtx = SignInProps & {
44+
export type SignInCtx = WithInternalRouting<SignInProps> & {
4445
componentName: 'SignIn';
4546
mode?: ComponentMode;
4647
};
4748

48-
export type UserVerificationCtx = __internal_UserVerificationProps & {
49+
export type UserVerificationCtx = WithInternalRouting<__internal_UserVerificationProps> & {
4950
componentName: 'UserVerification';
5051
mode?: ComponentMode;
5152
};
5253

53-
export type UserProfileCtx = UserProfileProps & {
54+
export type UserProfileCtx = WithInternalRouting<UserProfileProps> & {
5455
componentName: 'UserProfile';
5556
mode?: ComponentMode;
5657
};
5758

58-
export type SignUpCtx = SignUpProps & {
59+
export type SignUpCtx = WithInternalRouting<SignUpProps> & {
5960
componentName: 'SignUp';
6061
mode?: ComponentMode;
6162
emailLinkRedirectUrl?: string;
@@ -67,12 +68,12 @@ export type UserButtonCtx = UserButtonProps & {
6768
mode?: ComponentMode;
6869
};
6970

70-
export type OrganizationProfileCtx = OrganizationProfileProps & {
71+
export type OrganizationProfileCtx = WithInternalRouting<OrganizationProfileProps> & {
7172
componentName: 'OrganizationProfile';
7273
mode?: ComponentMode;
7374
};
7475

75-
export type CreateOrganizationCtx = CreateOrganizationProps & {
76+
export type CreateOrganizationCtx = WithInternalRouting<CreateOrganizationProps> & {
7677
componentName: 'CreateOrganization';
7778
mode?: ComponentMode;
7879
};

‎packages/types/src/clerk.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,10 @@ type RouterFn = (
831831

832832
export type WithoutRouting<T> = Omit<T, 'path' | 'routing'>;
833833

834+
export type WithInternalRouting<T> =
835+
| (Omit<T, 'routing' | 'path'> & { path: string | undefined; routing?: Extract<RoutingStrategy, 'path'> })
836+
| (Omit<T, 'routing' | 'path'> & { path?: never; routing?: Extract<RoutingStrategy, 'hash' | 'virtual'> });
837+
834838
export type SignInInitialValues = {
835839
emailAddress?: string;
836840
phoneNumber?: string;
@@ -892,7 +896,7 @@ export type SetActive = (params: SetActiveParams) => Promise<void>;
892896

893897
export type RoutingOptions =
894898
| { path: string | undefined; routing?: Extract<RoutingStrategy, 'path'> }
895-
| { path?: never; routing?: Extract<RoutingStrategy, 'hash' | 'virtual'> };
899+
| { path?: never; routing?: Extract<RoutingStrategy, 'hash'> };
896900

897901
export type SignInProps = RoutingOptions & {
898902
/**

0 commit comments

Comments
 (0)
Please sign in to comment.