From d7f353e79cdff8afffed8be5edcc5bdea58b13d8 Mon Sep 17 00:00:00 2001 From: pamapa Date: Tue, 10 Dec 2024 13:06:44 +0100 Subject: [PATCH] fix: use React.JSX instead of the global JSX namespace --- docs/react-oidc-context.api.md | 4 ++-- src/AuthProvider.tsx | 2 +- src/withAuthenticationRequired.tsx | 4 ++-- test/helpers.tsx | 2 +- test/withAuth.test.tsx | 4 ++-- test/withAuthenticationRequired.test.tsx | 16 ++++++++-------- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/react-oidc-context.api.md b/docs/react-oidc-context.api.md index c26a90eb..952b5a6d 100644 --- a/docs/react-oidc-context.api.md +++ b/docs/react-oidc-context.api.md @@ -58,7 +58,7 @@ export interface AuthContextProps extends AuthState { } // @public -export const AuthProvider: (props: AuthProviderProps) => JSX.Element; +export const AuthProvider: (props: AuthProviderProps) => React_2.JSX.Element; // @public (undocumented) export interface AuthProviderBaseProps { @@ -107,7 +107,7 @@ export const withAuthenticationRequired:

(Component: React_2.C // @public (undocumented) export interface WithAuthenticationRequiredProps { onBeforeSignin?: () => Promise | void; - OnRedirecting?: () => JSX.Element; + OnRedirecting?: () => React_2.JSX.Element; signinRedirectArgs?: SigninRedirectArgs; } diff --git a/src/AuthProvider.tsx b/src/AuthProvider.tsx index aa9349be..dca288a4 100644 --- a/src/AuthProvider.tsx +++ b/src/AuthProvider.tsx @@ -152,7 +152,7 @@ const UserManagerImpl = * * @public */ -export const AuthProvider = (props: AuthProviderProps): JSX.Element => { +export const AuthProvider = (props: AuthProviderProps): React.JSX.Element => { const { children, diff --git a/src/withAuthenticationRequired.tsx b/src/withAuthenticationRequired.tsx index 14751c0d..a7030ae2 100644 --- a/src/withAuthenticationRequired.tsx +++ b/src/withAuthenticationRequired.tsx @@ -11,7 +11,7 @@ export interface WithAuthenticationRequiredProps { /** * Show a message when redirected to the signin page. */ - OnRedirecting?: () => JSX.Element; + OnRedirecting?: () => React.JSX.Element; /** * Allows executing logic before the user is redirected to the signin page. @@ -35,7 +35,7 @@ export const withAuthenticationRequired =

( Component: React.ComponentType

, options: WithAuthenticationRequiredProps = {}, ): React.FC

=> { - const { OnRedirecting = (): JSX.Element => <>, onBeforeSignin, signinRedirectArgs } = options; + const { OnRedirecting = (): React.JSX.Element => <>, onBeforeSignin, signinRedirectArgs } = options; const displayName = `withAuthenticationRequired(${Component.displayName || Component.name})`; const C: React.FC

= (props) => { const auth = useAuth(); diff --git a/test/helpers.tsx b/test/helpers.tsx index fbc0cf53..5c04bdda 100644 --- a/test/helpers.tsx +++ b/test/helpers.tsx @@ -3,7 +3,7 @@ import React from "react"; import { AuthProvider, type AuthProviderProps } from "../src/AuthProvider"; export const createWrapper = (opts: AuthProviderProps, strictMode = true) => { - const AllProviders = ({ children }: React.PropsWithChildren): JSX.Element => { + const AllProviders = ({ children }: React.PropsWithChildren): React.JSX.Element => { const provider = {children}; if (!strictMode) { return provider; diff --git a/test/withAuth.test.tsx b/test/withAuth.test.tsx index c348142d..aa553c88 100644 --- a/test/withAuth.test.tsx +++ b/test/withAuth.test.tsx @@ -10,7 +10,7 @@ describe("withAuth", () => { it("should wrap a class component, adding AuthContextProps to the component's `auth` prop", async () => { // arrange class MyComponent extends Component { - render(): JSX.Element { + render(): React.JSX.Element { for (const [k, v] of Object.entries(this.props)) { if (k === "auth") { return <>{k}: {Object.keys(v as Map)}; @@ -34,7 +34,7 @@ describe("withAuth", () => { it("should pass through wrapped component props", async () => { // arrange class MyPropsComponent extends Component<{ originalProp: string }> { - render(): JSX.Element { + render(): React.JSX.Element { return <>originalPropValue: {this.props.originalProp}; } } diff --git a/test/withAuthenticationRequired.test.tsx b/test/withAuthenticationRequired.test.tsx index 8a0c7eaf..f0ced8c7 100644 --- a/test/withAuthenticationRequired.test.tsx +++ b/test/withAuthenticationRequired.test.tsx @@ -15,7 +15,7 @@ describe("withAuthenticationRequired", () => { authContext.signinRedirect = signinRedirectMock; useAuthMock.mockReturnValue(authContext); - const MyComponent = (): JSX.Element => <>Private; + const MyComponent = (): React.JSX.Element => <>Private; const WrappedComponent = withAuthenticationRequired(MyComponent); // act @@ -40,7 +40,7 @@ describe("withAuthenticationRequired", () => { authContext.signinRedirect = signinRedirectMock; useAuthMock.mockReturnValue(authContext); - const MyComponent = (): JSX.Element => <>Private; + const MyComponent = (): React.JSX.Element => <>Private; const WrappedComponent = withAuthenticationRequired(MyComponent); // act @@ -67,8 +67,8 @@ describe("withAuthenticationRequired", () => { authContext.signinRedirect = signinRedirectMock; useAuthMock.mockReturnValue(authContext); - const MyComponent = (): JSX.Element => <>Private; - const OnRedirecting = (): JSX.Element => <>Redirecting; + const MyComponent = (): React.JSX.Element => <>Private; + const OnRedirecting = (): React.JSX.Element => <>Redirecting; const WrappedComponent = withAuthenticationRequired(MyComponent, { OnRedirecting, }); @@ -94,7 +94,7 @@ describe("withAuthenticationRequired", () => { authContext.signinRedirect = signinRedirectMock; useAuthMock.mockReturnValue(authContext); - const MyComponent = (): JSX.Element => <>Private; + const MyComponent = (): React.JSX.Element => <>Private; const onBeforeSigninMock = jest.fn(); const WrappedComponent = withAuthenticationRequired(MyComponent, { onBeforeSignin: onBeforeSigninMock, @@ -124,7 +124,7 @@ describe("withAuthenticationRequired", () => { authContext.signinRedirect = signinRedirectMock; useAuthMock.mockReturnValue(authContext); - const MyComponent = (): JSX.Element => <>Private; + const MyComponent = (): React.JSX.Element => <>Private; const WrappedComponent = withAuthenticationRequired(MyComponent, { signinRedirectArgs: { redirect_uri: "foo", @@ -156,9 +156,9 @@ describe("withAuthenticationRequired", () => { authContext.signinRedirect = signinRedirectMock; useAuthMock.mockReturnValue(authContext); - const MyComponent = (): JSX.Element => <>Private; + const MyComponent = (): React.JSX.Element => <>Private; const WrappedComponent = withAuthenticationRequired(MyComponent); - const App = ({ foo }: { foo: number }): JSX.Element => ( + const App = ({ foo }: { foo: number }): React.JSX.Element => (

{foo}