From 49afc862c8f09069c9fdc64e7f39d5aa7cfcb409 Mon Sep 17 00:00:00 2001 From: panteliselef Date: Sat, 15 Jul 2023 09:58:50 +0300 Subject: [PATCH] chore(clerk-react): Mark `setSession` as deprecated This function was already deprecated but was not marked as such when re-exported from the hooks --- .changeset/tame-tomatoes-develop.md | 5 ++++ packages/react/src/hooks/useSessionList.ts | 29 +++++++++++++++++++--- packages/react/src/hooks/useSignIn.ts | 26 +++++++++++++++++-- packages/react/src/hooks/useSignUp.ts | 26 +++++++++++++++++-- packages/types/src/clerk.ts | 2 +- 5 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 .changeset/tame-tomatoes-develop.md diff --git a/.changeset/tame-tomatoes-develop.md b/.changeset/tame-tomatoes-develop.md new file mode 100644 index 00000000000..478eb858d6c --- /dev/null +++ b/.changeset/tame-tomatoes-develop.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-react': patch +--- + +Mark setSession as deprecated when it is re-exported within hooks diff --git a/packages/react/src/hooks/useSessionList.ts b/packages/react/src/hooks/useSessionList.ts index 3c59ebc910e..ec8f4b0f903 100644 --- a/packages/react/src/hooks/useSessionList.ts +++ b/packages/react/src/hooks/useSessionList.ts @@ -1,11 +1,34 @@ -import type { SetActive, SessionResource, SetSession } from '@clerk/types'; +import type { SessionResource, SetActive, SetSession } from '@clerk/types'; import { useClientContext } from '../contexts/ClientContext'; import { useIsomorphicClerkContext } from '../contexts/IsomorphicClerkContext'; type UseSessionListReturn = - | { isLoaded: false; sessions: undefined; setSession: undefined; setActive: undefined } - | { isLoaded: true; sessions: SessionResource[]; setSession: SetSession; setActive: SetActive }; + | { + isLoaded: false; + sessions: undefined; + /** + * @deprecated This method is deprecated and will be removed in the future. Use {@link Clerk.setActive} instead + * Set the current session explicitly. Setting the session to `null` unsets the active session and signs out the user. + * @param session Passed session resource object, session id (string version) or null + * @param beforeEmit Callback run just before the active session is set to the passed object. Can be used to hook up for pre-navigation actions. + */ + setSession: undefined; + setActive: undefined; + } + | { + isLoaded: true; + sessions: SessionResource[]; + + /** + * @deprecated This method is deprecated and will be removed in the future. Use {@link Clerk.setActive} instead + * Set the current session explicitly. Setting the session to `null` unsets the active session and signs out the user. + * @param session Passed session resource object, session id (string version) or null + * @param beforeEmit Callback run just before the active session is set to the passed object. Can be used to hook up for pre-navigation actions. + */ + setSession: SetSession; + setActive: SetActive; + }; type UseSessionList = () => UseSessionListReturn; diff --git a/packages/react/src/hooks/useSignIn.ts b/packages/react/src/hooks/useSignIn.ts index 5ba11c003f2..cf71a261ad1 100644 --- a/packages/react/src/hooks/useSignIn.ts +++ b/packages/react/src/hooks/useSignIn.ts @@ -4,8 +4,30 @@ import { useClientContext } from '../contexts/ClientContext'; import { useIsomorphicClerkContext } from '../contexts/IsomorphicClerkContext'; type UseSignInReturn = - | { isLoaded: false; signIn: undefined; setSession: undefined; setActive: undefined } - | { isLoaded: true; signIn: SignInResource; setSession: SetSession; setActive: SetActive }; + | { + isLoaded: false; + signIn: undefined; + /** + * @deprecated This method is deprecated and will be removed in the future. Use {@link Clerk.setActive} instead + * Set the current session explicitly. Setting the session to `null` unsets the active session and signs out the user. + * @param session Passed session resource object, session id (string version) or null + * @param beforeEmit Callback run just before the active session is set to the passed object. Can be used to hook up for pre-navigation actions. + */ + setSession: undefined; + setActive: undefined; + } + | { + isLoaded: true; + signIn: SignInResource; + /** + * @deprecated This method is deprecated and will be removed in the future. Use {@link Clerk.setActive} instead + * Set the current session explicitly. Setting the session to `null` unsets the active session and signs out the user. + * @param session Passed session resource object, session id (string version) or null + * @param beforeEmit Callback run just before the active session is set to the passed object. Can be used to hook up for pre-navigation actions. + */ + setSession: SetSession; + setActive: SetActive; + }; type UseSignIn = () => UseSignInReturn; diff --git a/packages/react/src/hooks/useSignUp.ts b/packages/react/src/hooks/useSignUp.ts index 8a8bd9c4c4a..182b9015388 100644 --- a/packages/react/src/hooks/useSignUp.ts +++ b/packages/react/src/hooks/useSignUp.ts @@ -4,8 +4,30 @@ import { useClientContext } from '../contexts/ClientContext'; import { useIsomorphicClerkContext } from '../contexts/IsomorphicClerkContext'; type UseSignUpReturn = - | { isLoaded: false; signUp: undefined; setSession: undefined; setActive: undefined } - | { isLoaded: true; signUp: SignUpResource; setSession: SetSession; setActive: SetActive }; + | { + isLoaded: false; + signUp: undefined; + /** + * @deprecated This method is deprecated and will be removed in the future. Use {@link Clerk.setActive} instead + * Set the current session explicitly. Setting the session to `null` unsets the active session and signs out the user. + * @param session Passed session resource object, session id (string version) or null + * @param beforeEmit Callback run just before the active session is set to the passed object. Can be used to hook up for pre-navigation actions. + */ + setSession: undefined; + setActive: undefined; + } + | { + isLoaded: true; + signUp: SignUpResource; + /** + * @deprecated This method is deprecated and will be removed in the future. Use {@link Clerk.setActive} instead + * Set the current session explicitly. Setting the session to `null` unsets the active session and signs out the user. + * @param session Passed session resource object, session id (string version) or null + * @param beforeEmit Callback run just before the active session is set to the passed object. Can be used to hook up for pre-navigation actions. + */ + setSession: SetSession; + setActive: SetActive; + }; type UseSignUp = () => UseSignUpReturn; diff --git a/packages/types/src/clerk.ts b/packages/types/src/clerk.ts index a3d722f9ab4..43b2efb8fa6 100644 --- a/packages/types/src/clerk.ts +++ b/packages/types/src/clerk.ts @@ -278,7 +278,7 @@ export interface Clerk { /** * @deprecated This method is deprecated and will be removed in the future. Use {@link Clerk.setActive} instead - * Set the current session explicitly. Setting the session to `null` deletes the active session. + * Set the current session explicitly. Setting the session to `null` unsets the active session and signs out the user. * @param session Passed session resource object, session id (string version) or null * @param beforeEmit Callback run just before the active session is set to the passed object. Can be used to hook up for pre-navigation actions. */