-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(clerk-react): Align types between Clerk and IsomorphicClerk #5197
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: a7247a8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
type WithVoidReturn<F extends (...args: any) => any> = ( | ||
...args: Parameters<F> | ||
) => ReturnType<F> extends Promise<infer T> ? Promise<T | void> : ReturnType<F> | void; | ||
type WithVoidReturnFunctions<T> = { | ||
[K in keyof T]: T[K] extends (...args: any) => any ? WithVoidReturn<T[K]> : T[K]; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most methods were adjust to add | void
to the return type, so I've gone ahead and created a helper type to do that automatically.
WithVoidReturnFunctions<LoadedClerk>, | ||
'client' | '__internal_addNavigationListener' | '__internal_getCachedResources' | '__internal_reloadInitialResources' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we need the __internal_
methods here, they don't exist today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, some of the internals we need some we don't. I know that __internal_addNavigationListener
is only needed within clerk-js, which makes me think we can refactor it 🤔.
@@ -574,27 +488,27 @@ export class IsomorphicClerk implements IsomorphicLoadedClerk { | |||
clerkjs.openWaitlist(this.preOpenWaitlist); | |||
} | |||
|
|||
this.premountSignInNodes.forEach((props: SignInProps, node: HTMLDivElement) => { | |||
this.premountSignInNodes.forEach((props, node) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also removed unnecessary type annotations and instead am relying on the underlying IsomorphicClerk
type definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
@@ -1113,10 +1026,10 @@ export class IsomorphicClerk implements IsomorphicLoadedClerk { | |||
} | |||
}; | |||
|
|||
handleGoogleOneTapCallback = ( | |||
handleGoogleOneTapCallback = async ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚨 Technically this is a breaking change at the type level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This aligns with the underlying Clerk type I believe 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here: https://github.com/clerk/javascript/blob/main/packages/types/src/clerk.ts#L540-L544
Another reason to ensure these types are sourced from the same place 😅
!snapshot |
Hey @panteliselef - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact |
Description
Aligns types between
IsomorphicClerk
andClerk
to ensure the implementation remains in sync.Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change