fix(*): improve role autocomplete for server-side has() - #9435
fix(*): improve role autocomplete for server-side has()#9435bradlocking wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 6812d75 The changes in this PR will be included in the next version bump. This PR includes changesets to release 23 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 |
|
@bradlocking is attempting to deploy a commit to the Clerk Production Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
📝 WalkthroughWalkthroughThe shared session-claims authorization types now accept a generic custom role key and use it for the Estimated code review effort: 2 (Simple) | ~10 minutes Mergeability Score: ⚪ Minimal · up to This localized type-autocomplete change is merge-ready after normal checks and review; no actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Warning Review ran into problems🔥 ProblemsRepository analysis: Couldn't refresh Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
Server-side
has({ role })andauth.protect({ role })did not offer IDE string-literal completions for custom Roles defined viaClerkAuthorization, even though the values were type-checked correctly. Permission checks already completed because they go through a generic type parameter.This change adds an optional Role generic (
R) alongside the existing Permission generic (P) onCheckAuthorizationFromSessionClaims/CheckAuthorizationParamsFromSessionClaims, and mirrors it onauth.protect()in@clerk/nextjs. Defaults keep the change backwards-compatible.Verified locally: with a custom
ClerkAuthorization,has({ role: "|" })now suggests Role literals the same waypermissiondoes.Checklist
pnpm testruns as expected.pnpm buildruns as expected.(If applicable) JSDoc comments have been added or updated for any package exports(If applicable) Documentation has been updatedType of change