-
Couldn't load subscription status.
- Fork 402
fix(types): Change return type of SetActiveNavigate to allow void or Promise #6662
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
Conversation
🦋 Changeset detectedLatest commit: 4708765 The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 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 GitHub.
|
WalkthroughUpdated the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
✨ Finishing Touches🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/types/src/clerk.ts (3)
1218-1234: Update docs/example to reflect sync callback.The example under
SetActiveParams.navigatestill shows anasyncarrow; it’s no longer required. Suggest revising to demonstrate a sync callback.@@ - * await clerk.setActive({ - * session, - * navigate: async ({ session }) => { + * await clerk.setActive({ + * session, + * // navigate can be sync or async; returning a value is ignored. + * navigate: ({ session }) => { * const currentTask = session.currentTask; * if (currentTask) { - * await router.push(`/onboarding/${currentTask.key}`) + * router.push(`/onboarding/${currentTask.key}`) * return * } * * router.push('/dashboard'); * } * });
123-124: Add JSDoc on the public type to clarify the contract.Explicitly document that return values are ignored and the function may be sync or async.
export type BeforeEmitCallback = (session?: SignedInSessionResource | null) => void | Promise<any>; - export type SetActiveNavigate = ({ session }: { session: SessionResource }) => void | Promise<unknown>; + /** + * Callback invoked just before committing the new active session/organization. + * May be synchronous or asynchronous. Any returned value is ignored. + */ + export type SetActiveNavigate = ({ session }: { session: SessionResource }) => void | Promise<unknown>;
123-123: Optional: consider a sharedAwaitableutility and tightening tovoid.Define
type Awaitable<T = void> = T | Promise<T>and useAwaitable<void>here. It clarifies intent (no meaningful return) and can unify other unions (Promise<unknown> | void) across this file.Example:
export type Awaitable<T = void> = T | Promise<T>; export type SetActiveNavigate = ({ session }: { session: SessionResource }) => Awaitable<void>;
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
packages/types/src/clerk.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/types/src/clerk.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/types/src/clerk.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/types/src/clerk.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/types/src/clerk.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertionsfor literal types:as const
Usesatisfiesoperator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/types/src/clerk.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/types/src/clerk.ts
🧬 Code graph analysis (1)
packages/types/src/clerk.ts (1)
packages/types/src/session.ts (1)
SessionResource(208-261)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Build Packages
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (2)
packages/types/src/clerk.ts (2)
123-123: Allowing sync navigate callbacks is correct and backward-compatible.Loosening
SetActiveNavigatetovoid | Promise<unknown>matches existing patterns (e.g.,CustomNavigation) and removes the need for gratuitousasync. Looks good.
95-98: Restrict fixes tofinalizeimplementations only
Your ripgrep scan surfaced everyreturn navigate(...)across UI and core code, but onlyasync finalize(params?: { navigate?: SetActiveNavigate }) => Promise<void>implementations risk aPromise<unknown>vsPromise<void>mismatch. Locate each checkout‐cachefinalizemethod—i.e. where you receiveparams.navigate—and replace anyreturn params.navigate!(…);with
await params.navigate!(…); return;
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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.changeset/nice-pans-jog.md (1)
6-6: Stray character at end of file.There’s an unexpected
6on the last line that looks accidental and could be confusing in the release note.-6 +
🧹 Nitpick comments (1)
.changeset/nice-pans-jog.md (1)
5-5: Clarify the body and include the exact type plus a brief migration note.Consider stating the precise signature and adding a short rationale/example so release notes are self-contained.
-fix(types): Change return type of SetActiveNavigate to allow void or Promise +fix(types): allow sync or async navigate callback in SetActiveNavigate + +SetActiveNavigate now returns `void | Promise<void>` so callers don't need to mark +the navigate callback as `async` purely for typing purposes. + +Before: +```ts +await signIn.finalize({ + navigate: async () => { router.push('/dashboard'); }, +}); +``` +After: +```ts +await signIn.finalize({ + navigate: () => { router.push('/dashboard'); }, +}); +```
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
.changeset/nice-pans-jog.md(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/**
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Automated releases must use Changesets.
Files:
.changeset/nice-pans-jog.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: Unit Tests (18, --filter=@clerk/astro --filter=@clerk/backend --filter=@clerk/express --filter=@c...
- GitHub Check: Static analysis
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
.changeset/nice-pans-jog.md (1)
1-3: Frontmatter looks correct for a patch release of @clerk/types.This will bump @clerk/types with a patch as intended.
| --- | ||
| "@clerk/types": patch | ||
| --- | ||
|
|
||
| fix(types): Change return type of SetActiveNavigate to allow void or Promise |
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.
💡 Verification agent
🧩 Analysis chain
Verify consistency with the actual type change across the repo.
Ensure the exported type is exactly void | Promise<void> (not Promise<unknown>) everywhere it’s declared or re-exported.
🏁 Script executed:
#!/bin/bash
# Verify SetActiveNavigate declaration(s) and references align with the changeset.
# 1) Locate the type definition(s)
rg -nP -C2 --type=ts 'export\s+type\s+SetActiveNavigate\b.*='
# 2) Show the return type in context
rg -nP -C3 --type=ts '(SetActiveNavigate|navigate\s*:\s*\(\{?\s*session)' | sed -n '1,200p'
# 3) Check for Promise<unknown> vs Promise<void> usage nearby
rg -nP --type=ts 'Promise<unknown>|Promise<void>'
# 4) Confirm no other packages declare their own SetActiveNavigate that would also need a changeset
rg -nP --type=ts '\bSetActiveNavigate\b' -g '!node_modules/**'Length of output: 38291
Change SetActiveNavigate return type to void | Promise
In packages/types/src/clerk.ts line 123, update
export type SetActiveNavigate = ({ session }: { session: SessionResource }) => void | Promise<unknown>;to
export type SetActiveNavigate = ({ session }: { session: SessionResource }) => void | Promise<void>;and ensure all imports/uses (e.g. useCheckout.ts, SignInFuture, SignUpFuture, clerk-js checkout) and related tests align with the new Promise<void> signature.
🤖 Prompt for AI Agents
In .changeset/nice-pans-jog.md lines 1-5: update the type in
packages/types/src/clerk.ts (around line 123) from Promise<unknown> to
Promise<void> for SetActiveNavigate so its signature becomes ({ session }: {
session: SessionResource }) => void | Promise<void>; then update all usages and
imports (e.g., useCheckout.ts, SignInFuture, SignUpFuture, clerk-js checkout) to
return either void or Promise<void> (adjust async functions to return/resolve
with no value) and update related tests to expect/await Promise<void> results or
to not assert on returned value.
Description
So that adding
asyncjust to make TS happy is no longer needed:Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit