Skip to content

Conversation

@alexcarpenter
Copy link
Member

@alexcarpenter alexcarpenter commented Feb 12, 2025

Description

  • Mark EmailLinkErrorCode as deprecated
  • Introduce EmailLinkErrorCodeStatus
import { EmailLinkErrorCodeStatus } from '@clerk/nextjs/errors'

type EmailLinkError = typeof EmailLinkErrorCodeStatus[keyof typeof EmailLinkErrorCodeStatus];

const getStatus = (err: EmailLinkError): EmailLinkError => {
  if (err === EmailLinkErrorCodeStatus.Expired) {
    return 'expired'
  }

  if (err === EmailLinkErrorCodeStatus.ClientMismatch) {
    return 'client_mismatch'
  }

  return 'failed'
}

Resolves SDK-2055

Checklist

  • pnpm test runs as expected.
  • pnpm 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:

@changeset-bot
Copy link

changeset-bot bot commented Feb 12, 2025

🦋 Changeset detected

Latest commit: afe8949

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

This PR includes changesets to release 20 packages
Name Type
@clerk/react-router Minor
@clerk/clerk-js Minor
@clerk/nextjs Minor
@clerk/shared Minor
@clerk/clerk-react Minor
@clerk/remix Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/elements Patch
@clerk/expo-passkeys Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nuxt Patch
@clerk/tanstack-start Patch
@clerk/testing Patch
@clerk/ui Patch
@clerk/vue 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

@vercel
Copy link

vercel bot commented Feb 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ⬜️ Skipped (Inspect) Feb 13, 2025 2:44pm

Copy link
Member

@dstaley dstaley left a comment

Choose a reason for hiding this comment

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

lgtm but this is technically a breaking change in the most technical sense given that we're narrowing EmailLinkErrorCode from Record<string, string> to a more restrictive type. I think this is probably fine, but there's technically user code that could break as a result of this change.

@alexcarpenter alexcarpenter marked this pull request as draft February 12, 2025 21:28
@alexcarpenter alexcarpenter changed the title feat(shared): Cast EmailLinkErrorCode as const feat(shared): Introduce EmailLinkErrorCodeStatus and deprecate EmailLinkErrorCode Feb 12, 2025
@alexcarpenter alexcarpenter changed the title feat(shared): Introduce EmailLinkErrorCodeStatus and deprecate EmailLinkErrorCode feat(clerk-js,shared,nextjs,react-router,react,remix): Introduce EmailLinkErrorCodeStatus and deprecate EmailLinkErrorCode Feb 12, 2025
@alexcarpenter alexcarpenter changed the title feat(clerk-js,shared,nextjs,react-router,react,remix): Introduce EmailLinkErrorCodeStatus and deprecate EmailLinkErrorCode feat(clerk-js,shared,nextjs,react-router,react,remix): Introduce EmailLinkErrorCodeStatus Feb 12, 2025
@alexcarpenter alexcarpenter changed the title feat(clerk-js,shared,nextjs,react-router,react,remix): Introduce EmailLinkErrorCodeStatus feat(clerk-js,shared,nextjs,react-router,clerk-react,remix): Introduce EmailLinkErrorCodeStatus Feb 12, 2025
isKnownError,
isMetamaskError,
EmailLinkErrorCode,
EmailLinkErrorCodeStatus,
Copy link
Member

Choose a reason for hiding this comment

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

We need to re-export it from src/errors.ts


```diff
- import { EmailLinkErrorCode } from '@clerk/nextjs/errors'
+ import { EmailLinkErrorCodeStatus } from '@clerk/nextjs/errors'
Copy link
Member

Choose a reason for hiding this comment

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

We need to re-export EmailLinkErrorCodeStatus from src/errors.ts

Copy link
Member

@panteliselef panteliselef left a comment

Choose a reason for hiding this comment

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

Nice work

@alexcarpenter alexcarpenter merged commit d76c469 into main Feb 13, 2025
29 checks passed
@alexcarpenter alexcarpenter deleted the alexcarpenter/email-link-error-code-as-const branch February 13, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants