Skip to content

Commit 1f8e652

Browse files
committed
typing tweak
1 parent c9f3d62 commit 1f8e652

File tree

7 files changed

+22
-21
lines changed

7 files changed

+22
-21
lines changed

packages/astro/src/react/controlComponents.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { PropsWithChildren } from 'react';
44
import React, { useEffect, useState } from 'react';
55

66
import { $csrState } from '../stores/internal';
7-
import type { ProtectProps as _ProtectProps } from '../types';
7+
import type { ProtectParams } from '@clerk/shared/types';
88
import { useAuth } from './hooks';
99
import type { WithClerkProp } from './utils';
1010
import { withClerk } from './utils';
@@ -70,7 +70,7 @@ export const ClerkLoading = ({ children }: React.PropsWithChildren): JSX.Element
7070
};
7171

7272
export type ProtectProps = React.PropsWithChildren<
73-
_ProtectProps & { fallback?: React.ReactNode } & PendingSessionOptions
73+
ProtectParams & { fallback?: React.ReactNode } & PendingSessionOptions
7474
>;
7575

7676
/**

packages/chrome-extension/src/__tests__/__snapshots__/exports.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ exports[`public exports > should not include a breaking change 1`] = `
1515
"OrganizationProfile",
1616
"OrganizationSwitcher",
1717
"PricingTable",
18-
"Protect",
1918
"RedirectToCreateOrganization",
2019
"RedirectToOrganizationProfile",
2120
"RedirectToSignIn",
2221
"RedirectToSignUp",
2322
"RedirectToUserProfile",
23+
"Show",
2424
"SignIn",
2525
"SignInButton",
2626
"SignInWithMetamaskButton",

packages/chrome-extension/src/react/re-exports.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ export {
1010
OrganizationProfile,
1111
OrganizationSwitcher,
1212
PricingTable,
13-
Protect,
1413
RedirectToCreateOrganization,
1514
RedirectToOrganizationProfile,
1615
RedirectToSignIn,
1716
RedirectToSignUp,
1817
RedirectToUserProfile,
18+
Show,
1919
SignIn,
2020
SignInButton,
2121
SignInWithMetamaskButton,

packages/nextjs/src/app-router/server/controlComponents.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { PendingSessionOptions, ProtectProps as _ProtectProps } from '@clerk/shared/types';
1+
import type { PendingSessionOptions, ProtectParams } from '@clerk/shared/types';
22
import React from 'react';
33

44
import { auth } from './auth';
55

6-
type ProtectProps = React.PropsWithChildren<
7-
_ProtectProps & {
6+
export type AppRouterProtectProps = React.PropsWithChildren<
7+
ProtectParams & {
88
fallback?: React.ReactNode;
99
} & PendingSessionOptions
1010
>;
@@ -37,7 +37,7 @@ export async function SignedOut(
3737
* <Protect fallback={<p>Unauthorized</p>} />
3838
* ```
3939
*/
40-
export async function Protect(props: ProtectProps): Promise<React.JSX.Element | null> {
40+
export async function Protect(props: AppRouterProtectProps): Promise<React.JSX.Element | null> {
4141
const { children, fallback, ...restAuthorizedParams } = props;
4242
const { has, userId } = await auth({ treatPendingAsSignedOut: props.treatPendingAsSignedOut });
4343

packages/react/src/components/controlComponents.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import { deprecated } from '@clerk/shared/deprecated';
2-
import type {
3-
HandleOAuthCallbackParams,
4-
PendingSessionOptions,
5-
ShowProps as _ShowProps,
6-
ShowWhenCondition,
7-
} from '@clerk/shared/types';
2+
import type { HandleOAuthCallbackParams, PendingSessionOptions, ShowWhenCondition } from '@clerk/shared/types';
83
import React from 'react';
94

105
import { useIsomorphicClerkContext } from '../contexts/IsomorphicClerkContext';
@@ -75,7 +70,8 @@ export const ClerkDegraded = ({ children }: React.PropsWithChildren<unknown>) =>
7570
};
7671

7772
export type ShowProps = React.PropsWithChildren<
78-
_ShowProps & {
73+
{
74+
when: ShowWhenCondition;
7975
fallback?: React.ReactNode;
8076
} & PendingSessionOptions
8177
>;

packages/shared/src/types/protect.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import type { CheckAuthorizationWithCustomPermissions } from './session';
33
import type { Autocomplete } from './utils';
44

55
/**
6-
* Props for the `<Protect />` component, which restricts access to its children based on authentication and authorization.
6+
* Authorization parameters used by `<Protect />` and `auth.protect()`.
77
*
8-
* Use `ProtectProps` to specify the required role, permission, feature, or plan for access.
8+
* Use `ProtectParams` to specify the required role, permission, feature, or plan for access.
99
*
1010
* @example
1111
* ```tsx
@@ -22,10 +22,10 @@ import type { Autocomplete } from './utils';
2222
* <Protect feature="a_feature_key" />
2323
*
2424
* // Require a specific plan
25-
* <Protect plan=a_plan_key" />
25+
* <Protect plan="a_plan_key" />
2626
* ```
2727
*/
28-
export type ProtectProps =
28+
export type ProtectParams =
2929
| {
3030
condition?: never;
3131
role: OrganizationCustomRoleKey;
@@ -69,6 +69,11 @@ export type ProtectProps =
6969
plan?: never;
7070
};
7171

72+
/**
73+
* @deprecated Use {@link ProtectParams} instead.
74+
*/
75+
export type ProtectProps = ProtectParams;
76+
7277
/**
7378
* Authorization condition for the `when` prop in `<Show />`.
7479
* Can be an object specifying role, permission, feature, or plan,

packages/vue/src/components/controlComponents.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { deprecated } from '@clerk/shared/deprecated';
22
import type {
33
HandleOAuthCallbackParams,
44
PendingSessionOptions,
5-
ProtectProps as _ProtectProps,
5+
ProtectParams,
66
RedirectOptions,
77
} from '@clerk/shared/types';
88
import { defineComponent } from 'vue';
@@ -112,7 +112,7 @@ export const AuthenticateWithRedirectCallback = defineComponent((props: HandleOA
112112
return () => null;
113113
});
114114

115-
export type ProtectProps = _ProtectProps & PendingSessionOptions;
115+
export type ProtectProps = ProtectParams & PendingSessionOptions;
116116

117117
export const Protect = defineComponent((props: ProtectProps, { slots }) => {
118118
const { isLoaded, has, userId } = useAuth({ treatPendingAsSignedOut: props.treatPendingAsSignedOut });

0 commit comments

Comments
 (0)