Skip to content
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(repo,clerk-js): Update TS to v5 & Update emotion minor #1877

Merged
merged 2 commits into from
Oct 17, 2023

Conversation

LekoArts
Copy link
Member

@LekoArts LekoArts commented Oct 13, 2023

Description

So to be able to use the Bundler option in https://www.typescriptlang.org/tsconfig#moduleResolution we need TypeScript v5. 5.1 introduced something new for JSX: https://devblogs.microsoft.com/typescript/announcing-typescript-5-1/#decoupled-type-checking-between-jsx-elements-and-jsx-tag-types

To make TS v5 and emotion work, we need to update emotion a little bit.
Both updates are harmless:

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Packages affected

  • @clerk/clerk-js
  • @clerk/clerk-react
  • @clerk/nextjs
  • @clerk/remix
  • @clerk/types
  • @clerk/themes
  • @clerk/localizations
  • @clerk/clerk-expo
  • @clerk/backend
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/fastify
  • @clerk/chrome-extension
  • gatsby-plugin-clerk
  • build/tooling/chore

@changeset-bot
Copy link

changeset-bot bot commented Oct 13, 2023

🦋 Changeset detected

Latest commit: caf1f2f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

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

@@ -85,7 +85,7 @@ export const ArrowBlockButton = (props: ArrowBlockButtonProps) => {
<Icon
elementDescriptor={leftIconElementDescriptor}
elementId={leftIconElementId}
icon={leftIcon}
icon={leftIcon as React.ComponentType}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is a bit complicated 😆
Due to https://github.com/clerkinc/javascript/blob/caf1f2fd1a8f7b187e152e0e095d01095b41ca98/packages/clerk-js/src/ui/elements/ArrowBlockButton.tsx#L12 this type here is wrong. But you just can't set it to the correct React.ComponentType because the type is referenced in other places (as a type alias).

So yeah, instead of fixing stuff in 10 places I just type-casted 🙈

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we need to fix the underlying type issue?
Can we either try to do it now or create a ticket with more details?

Copy link
Member Author

@LekoArts LekoArts Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know yet, since this would require some bigger investigation/changes rather than just keeping things as-is for now.

It comes down to us re-using the props here:

https://github.com/clerkinc/javascript/blob/8434782c53147e4e3333746fd6096212dfcaa51d/packages/clerk-js/src/ui/common/BlockButtons.tsx#L6

Then in other places we use it like this: https://github.com/clerkinc/javascript/blob/8434782c53147e4e3333746fd6096212dfcaa51d/packages/clerk-js/src/ui/components/SignIn/SignInAccountSwitcher.tsx#L51-L57

But the code I changed here only wants ComponentType:

https://github.com/clerkinc/javascript/blob/8434782c53147e4e3333746fd6096212dfcaa51d/packages/clerk-js/src/ui/primitives/Icon.tsx#L30

So it's a big problem and fixing this would block me from shipping the more important work

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type isn't actually wrong here, see the isIconElement boolean on L47 and handling the case where leftIcon is an element on L99. It seems that with the TS upgrade though the type narrowing isn't working as it was before 😞 :

Screenshot 2023-10-16 at 12 18 13 PM

I think @LekoArts's fix is good for now, we could also use @ts-expect-error and leave a comment stating we already have a type guard.

@@ -8,6 +8,7 @@
"declarationMap": false,
"sourceMap": false,
"outDir": "./dist",
"declarationDir": "./dist/types"
"declarationDir": "./dist/types",
"noImplicitReturns": false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only warn against this in our code (and have some instances where we need to fix this). During compilation then it fails unless turned off. Since we don't enforce it in our normal code I opted for this for now.

@LekoArts LekoArts marked this pull request as ready for review October 13, 2023 12:18
@LekoArts LekoArts requested a review from a team as a code owner October 13, 2023 12:18
Copy link
Member

@BRKalow BRKalow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving! I think we can opt to use @ts-expect-error instead of casting for the type issue, but either approach works.

@LekoArts LekoArts added this pull request to the merge queue Oct 17, 2023
Merged via the queue into main with commit 8000e3a Oct 17, 2023
11 of 12 checks passed
@LekoArts LekoArts deleted the lekoarts/js-803-update-ts-to-v5 branch October 17, 2023 06:45
@clerk-cookie clerk-cookie mentioned this pull request Oct 17, 2023
@clerk-cookie
Copy link
Collaborator

This PR has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@clerk clerk locked as resolved and limited conversation to collaborators Oct 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants