Skip to content

Conversation

@SarahSoutoul
Copy link
Contributor

@SarahSoutoul SarahSoutoul commented Oct 1, 2025

Description

Fixes https://linear.app/clerk/issue/DOCS-10983/ensure-all-hooks-are-using-typedocs-have-code-examples-for-each.

This PR is part of a broader project aimed at adding more code examples to our hooks documentation. During project discussions, we agreed that the current structure of our hooks docs needed to be revisited. Currently, most of the hook pages are fully rendered through Typedoc, including code examples. However, adding additional examples through Typedoc would have required significant restructuring of the JavaScript repo.

To address this, we decided to:

  • Use Typedoc only for documenting returns and parameters. This is achieved through this PR.
  • Write SDK-specific explanations and code examples directly in the docs instead of generating them via Typedoc. PR on clerk-docs for this: https://github.com/clerk/clerk-docs/pull/2649/files

Additionally, not all hooks currently use Typedoc. This PR also ensures that all hooks are properly configured to use Typedoc for their returns and parameters.

This PR includes:

  • Adding JSDoc comments to the billing hooks so their returns and parameters are correctly pulled from Typedoc.
  • Updating the documentation setup to ensure Typedoc is used only for returns and parameters, not for examples or SDK explanations.

This PR will be the first in a sequence. Once merged, we’ll proceed with its sibling PR in clerk-docs, which:

  • Adds code examples for all supported SDKs.
  • Ensures the updated Typedoc outputs are properly integrated into the docs site.

Hooks checklist

  • Check all the returns render properly for all hooks - can be compared to what's on the live docs (if you'd like a list of all the hooks to check, you can navigate to this PR's description).
  • Check the params render properly for useAuth, useReverification and the billing hooks - can be compared to what's on the live docs.

How to test

In order to test this properly, you will need to do the following:

  • On the javascript repo, switch to the branch of this PR
  • Run pnpm run typedoc:generate
  • Navigate to the clerk-docs repo, and switch to the branch of this PR - ss/DOCS-10983
  • Run npm run typedoc:link ../javascript/.typedoc/docs
  • Now, you can run the docs locally and be able to see the returns and params on each hook, coming through Typedoc.

Important notes/ discussion pts

  • I noticed we use the terminology Parameters for some hooks and for others, we use Properties: We probably want some consistency, so want to open this for discussion.
Screenshot 2025-10-14 at 8 31 46 am Screenshot 2025-10-14 at 8 35 22 am

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:

Summary by CodeRabbit

  • New Features

    • Enhanced TypeScript type exports for payment and checkout hooks, improving developer experience with clearer public API definitions.
  • Documentation

    • Added comprehensive JSDoc documentation for public types and hooks including useCheckout, usePaymentElement, and useSubscription.
    • Improved documentation generation system with enhanced file mappings and link replacements for better reference navigation.

@vercel
Copy link

vercel bot commented Oct 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Oct 30, 2025 9:42pm

@changeset-bot
Copy link

changeset-bot bot commented Oct 1, 2025

🦋 Changeset detected

Latest commit: 3029aa3

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

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 1, 2025

Walkthrough

This pull request refactors internal hook type definitions into properly exported public API types with JSDoc documentation, and introduces a TypeDoc extraction pipeline to automatically generate hook parameter and return type documentation during the build process.

Changes

Cohort / File(s) Summary
Commerce Hook API Surface
packages/shared/src/react/commerce.tsx
Exports three new public types: PaymentElementProviderProps (checkout, stripeAppearance, for, paymentDescription), PaymentElementProps (fallback), and UsePaymentElementReturn (submit, reset, isFormReady, provider state union). All include JSDoc documentation.
Checkout Hook API Surface
packages/shared/src/react/contexts.tsx, packages/shared/src/react/hooks/useCheckout.ts
Exports UseCheckoutOptions type and introduces new UseCheckoutReturn type aggregating fetch status, error handling, and checkout properties (confirm, start, clear, finalize, getState, isStarting, isConfirming). Replaces inline types and updates function signature to reference new types.
Reverification Hook API Surface
packages/shared/src/react/hooks/useReverification.ts
Exports NeedsReverificationParameters (cancel, complete, level) and UseReverificationOptions types. Simplifies UseReverification generic signature from two parameters to one (Fetcher only). Adds inline documentation for all members.
Subscription & Billing Hooks
packages/shared/src/react/hooks/useSubscription.tsx, packages/shared/src/react/hooks/usePlans.tsx, packages/shared/src/react/hooks/createBillingPaginatedHook.tsx
Exports UseSubscriptionParams, UseSubscriptionReturn, UsePlansReturn, and HookParams types with JSDoc annotations. Adds revalidate function to subscription return. Promotes previously local HookParams to exported interface.
Error Documentation
packages/shared/src/errors/clerkApiResponseError.ts
Adds JSDoc block to ClerkAPIResponseError class declaration. No logic changes.
Documentation Extraction Infrastructure
.typedoc/extract-returns-and-params.mjs
New Node.js script that processes MDX files in temp-docs directory. Extracts "## Returns" and "## Parameters" sections into separate -return.mdx and -params.mdx files. Replaces generic type patterns in parameters tables and deletes stale -props.mdx files.
Documentation Configuration
.typedoc/custom-plugin.mjs
Removes duplicate entry and adds numerous new MDX files to FILES_WITHOUT_HEADINGS. Expands LINK_REPLACEMENTS with new anchor mappings for use-checkout-options, use-reverification-options, needs-reverification-parameters, and billing resource types.
Build Process
package.json
Updates typedoc:generate:skip-build script to invoke node .typedoc/extract-returns-and-params.mjs between TypeDoc generation and cleanup steps.
Release Metadata
.changeset/violet-boxes-watch.md
Changeset specifying minor version bumps for Clerk packages with note to ensure all hooks use TypeDoc for docs.

Sequence Diagram

sequenceDiagram
    participant Build as Build Process
    participant TypeDoc as TypeDoc
    participant Extractor as extract-returns-and-params.mjs
    participant MDXFiles as MDX Files
    participant Output as Documentation Output

    Build->>TypeDoc: 1. Generate types documentation
    TypeDoc->>MDXFiles: Creates temp-docs with MDX
    
    Build->>Extractor: 2. Run extraction script
    Extractor->>MDXFiles: Read MDX files
    Extractor->>MDXFiles: Extract "## Returns" section
    MDXFiles->>Output: Write *-return.mdx
    Extractor->>MDXFiles: Extract "## Parameters" section
    MDXFiles->>Output: Write *-params.mdx
    
    rect rgb(220, 240, 255)
        Extractor->>Extractor: Replace generic type patterns<br/>in params tables
    end
    
    Extractor->>MDXFiles: Delete stale -props.mdx
    
    Build->>Build: 3. Cleanup & move docs
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Areas requiring extra attention:
    • .typedoc/extract-returns-and-params.mjs — New extraction script with file I/O operations; verify recursive MDX enumeration, section parsing logic, and generic type replacement pattern correctness
    • Type signature simplification in useReverification.ts — Confirm the removal of generic Options parameter doesn't break existing usage or type inference
    • .typedoc/custom-plugin.mjs link replacement mappings — Verify new anchor patterns match the generated documentation output structure

Poem

🐰✨ Types aligned in rows so neat,
Documentation now complete,
Returns extracted, params refined,
Every hook's API well-defined!
With TypeDoc's help, the docs are bright,
Public APIs shine just right! 🌟

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "docs(repo): Generate all params and return types (hooks work)" directly reflects the primary changes in this pull request. The changeset focuses on exporting hook-related types with JSDoc documentation (UseCheckoutReturn, UseCheckoutParams, UseReverificationOptions, NeedsReverificationParameters, UseSubscriptionReturn, UsePlansReturn, and others), adding a script to extract and organize these types from documentation, and integrating this into the build pipeline. The title accurately captures this core objective and is concise and specific about the work being done.
Linked Issues Check ✅ Passed The PR directly addresses DOCS-10983's core objectives by exporting typed metadata for multiple hooks via TypeDoc. The changes include exposing return and parameter types with JSDoc documentation for useCheckout, useReverification, useSubscription, usePlans, and billing-related hooks; creating a new extraction script to process these types from MDX files; updating TypeDoc configuration with link mappings for the new types; and integrating the extraction into the build pipeline. The PR description notes that SDK-specific explanations and code examples are being added in a sibling PR (clerk-docs), aligning with the objective to limit TypeDoc's role to params and returns. All coding-related requirements from DOCS-10983 are met in this PR.
Out of Scope Changes Check ✅ Passed All changes in this PR are directly aligned with the scope of DOCS-10983. The modifications to hook files (useCheckout.ts, useReverification.ts, useSubscription.tsx, usePlans.tsx, commerce.tsx, contexts.tsx, and createBillingPaginatedHook.tsx) all involve exporting hook types and parameters for TypeDoc extraction. The tooling changes (extract-returns-and-params.mjs, custom-plugin.mjs, package.json) implement the extraction and build integration necessary for the objective. The minor JSDoc addition to clerkApiResponseError.ts appears to be supporting documentation for TypeDoc consistency, as error classes may be referenced in hook returns. No out-of-scope refactoring, feature changes, or unrelated modifications are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ss/DOCS-10983

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9e4f120 and 3029aa3.

📒 Files selected for processing (1)
  • package.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • package.json
⏰ 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: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@SarahSoutoul SarahSoutoul changed the title Refactor Typedoc for hooks to support hook code examples on Clerk docs docs(repo): Refactor Typedoc for hooks to support hook code examples on Clerk docs Oct 1, 2025
@SarahSoutoul SarahSoutoul self-assigned this Oct 1, 2025
@SarahSoutoul SarahSoutoul changed the title docs(repo): Refactor Typedoc for hooks to support hook code examples on Clerk docs docs(repo): Generate all function params and return types Oct 2, 2025
@SarahSoutoul SarahSoutoul changed the title docs(repo): Generate all function params and return types docs(repo): Generate all params and return types (hooks work) Oct 2, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

♻️ Duplicate comments (1)
packages/shared/src/react/hooks/useSubscription.tsx (1)

38-56: Let data/error model SWR’s undefined state

useSWR yields undefined for both data and error before the first fetch, yet Line 40 narrows to BillingSubscriptionResource | null and Line 52 narrows to Error | null. That combination misleads consumers and mis-documents the initial state; it also contradicts the resolution from the earlier review thread. Please widen both fields to include undefined and update the JSDoc to match.

-  /**
-   * The subscription object, or `null` if the data hasn't been loaded yet.
-   */
-  data: BillingSubscriptionResource | null;
+  /**
+   * The subscription object. `undefined` before the first fetch, `null` when no subscription exists.
+   */
+  data: BillingSubscriptionResource | null | undefined;
@@
-  /**
-   * Any error that occurred during the data fetch, or `null` if no error occurred.
-   */
-  error: Error | null;
+  /**
+   * Any error that occurred during the data fetch, or `undefined` if no error occurred yet.
+   */
+  error: Error | undefined;
🧹 Nitpick comments (1)
packages/shared/src/react/hooks/useSubscription.tsx (1)

54-56: Expose the promise shape of revalidate

swr.mutate() resolves with the refreshed subscription (BillingSubscriptionResource | null | undefined). Typing Line 56 as Promise<void> hides that data from consumers and robs frictionless chaining. Please surface the actual resolved payload (and note it in the docstring).

-  /**
-   * Function to manually trigger a refresh of the subscription data.
-   */
-  revalidate: () => Promise<void>;
+  /**
+   * Function to manually trigger a refresh of the subscription data. Resolves with the latest subscription value.
+   */
+  revalidate: () => Promise<BillingSubscriptionResource | null | undefined>;
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5c29779 and 6b4f930.

📒 Files selected for processing (1)
  • packages/shared/src/react/hooks/useSubscription.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{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/shared/src/react/hooks/useSubscription.tsx
**/*.{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/shared/src/react/hooks/useSubscription.tsx
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/shared/src/react/hooks/useSubscription.tsx
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/shared/src/react/hooks/useSubscription.tsx
**/*.{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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for 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
Use const assertions for literal types: as const
Use satisfies operator 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for 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/shared/src/react/hooks/useSubscription.tsx
**/*.{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components

**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components: UserProfile, NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...

Files:

  • packages/shared/src/react/hooks/useSubscription.tsx
**/*.{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/shared/src/react/hooks/useSubscription.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

**/*.tsx: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering

Files:

  • packages/shared/src/react/hooks/useSubscription.tsx
🧬 Code graph analysis (1)
packages/shared/src/react/hooks/useSubscription.tsx (1)
packages/types/src/billing.ts (2)
  • ForPayerType (69-69)
  • BillingSubscriptionResource (565-615)
⏰ 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: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6b4f930 and 9df0c27.

📒 Files selected for processing (4)
  • packages/shared/src/errors/clerkApiResponseError.ts (1 hunks)
  • packages/shared/src/react/hooks/createBillingPaginatedHook.tsx (1 hunks)
  • packages/shared/src/react/hooks/usePlans.tsx (1 hunks)
  • packages/types/src/billing.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/shared/src/errors/clerkApiResponseError.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/types/src/billing.ts
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{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/shared/src/react/hooks/usePlans.tsx
  • packages/shared/src/react/hooks/createBillingPaginatedHook.tsx
**/*.{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/shared/src/react/hooks/usePlans.tsx
  • packages/shared/src/react/hooks/createBillingPaginatedHook.tsx
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/shared/src/react/hooks/usePlans.tsx
  • packages/shared/src/react/hooks/createBillingPaginatedHook.tsx
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/shared/src/react/hooks/usePlans.tsx
  • packages/shared/src/react/hooks/createBillingPaginatedHook.tsx
**/*.{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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for 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
Use const assertions for literal types: as const
Use satisfies operator 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for 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/shared/src/react/hooks/usePlans.tsx
  • packages/shared/src/react/hooks/createBillingPaginatedHook.tsx
**/*.{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components

**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components: UserProfile, NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...

Files:

  • packages/shared/src/react/hooks/usePlans.tsx
  • packages/shared/src/react/hooks/createBillingPaginatedHook.tsx
**/*.{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/shared/src/react/hooks/usePlans.tsx
  • packages/shared/src/react/hooks/createBillingPaginatedHook.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

**/*.tsx: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering

Files:

  • packages/shared/src/react/hooks/usePlans.tsx
  • packages/shared/src/react/hooks/createBillingPaginatedHook.tsx
🧬 Code graph analysis (2)
packages/shared/src/react/hooks/usePlans.tsx (2)
packages/clerk-js/src/ui/contexts/components/Plans.tsx (1)
  • usePlans (80-90)
packages/shared/src/react/hooks/index.ts (1)
  • usePlans (14-14)
packages/shared/src/react/hooks/createBillingPaginatedHook.tsx (2)
packages/shared/src/react/types.ts (2)
  • PaginatedHookConfig (90-103)
  • PagesOrInfiniteOptions (134-157)
packages/types/src/billing.ts (1)
  • ForPayerType (69-69)
⏰ 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: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (2)
packages/shared/src/react/hooks/usePlans.tsx (1)

24-27: I'll verify the review comment by examining the codebase and checking TypeScript/TypeDoc conventions.

Now let me examine the actual file and verify the pattern in the codebase:

Excellent! I found critical information. Now let me examine the actual file and check for patterns in the codebase:

Based on my research, I can now provide a definitive verification.



The review comment incorrectly flags the @interface tag usage. TypeDoc explicitly supports @interface on type aliases and will cause them to be converted as interfaces in documentation. This is a documented TypeDoc feature, not a mistake.

For the PR's TypeDoc documentation approach, using @interface on the type alias is the correct pattern. The suggestion to use @typedef is not applicable here, as @typedef is for JavaScript JSDoc in .js files, while this code is in a .tsx file with TypeScript type aliases documented for TypeDoc generation.

The only valid concern is the missing description. Per the coding guidelines, public APIs should be documented. Add a brief description of what this return type represents:

 /**
- * @interface
+ * Return type of the usePlans hook.
  */
 export type UsePlansReturn = ReturnType<typeof usePlans>;

Likely an incorrect or invalid review comment.

packages/shared/src/react/hooks/createBillingPaginatedHook.tsx (1)

30-37: LGTM! Property documentation is clear and accurate.

The for property is well-documented with a clear description and correct default value that matches the implementation at line 66 (_for || 'user'). The type constraint using ForPayerType is appropriate and type-safe.

Copy link
Member

@wobsoriano wobsoriano left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you 🚀

@SarahSoutoul
Copy link
Contributor Author

Looks good! Thank you 🚀

Thank you for reviewing @wobsoriano! Think I may want @NWylynko eyes on this too - want to make sure it's all good.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/shared/src/react/hooks/useReverification.ts (1)

70-72: Remove | undefined from Fetcher constraint.

The constraint permits undefined as a valid Fetcher, but the implementation requires an actual function. This weakens type safety and could allow invalid usage.

-type UseReverificationResult<Fetcher extends (...args: any[]) => Promise<any> | undefined> = (
+type UseReverificationResult<Fetcher extends (...args: any[]) => Promise<any>> = (
   ...args: Parameters<Fetcher>
 ) => Promise<ExcludeClerkError<Awaited<ReturnType<Fetcher>>>>;
♻️ Duplicate comments (2)
package.json (1)

59-59: Unresolved: Cross-platform script compatibility (previously flagged).

This issue was flagged in a prior review. The script at line 59 still uses POSIX-only rm and mv commands, which fail on Windows. The required cross-platform replacements (rimraf and cpy-cli) are already in devDependencies and available for use.

Apply this diff to make the script cross-platform:

-"typedoc:generate:skip-build": "typedoc --tsconfig tsconfig.typedoc.json && node .typedoc/extract-returns-and-params.mjs && rm -rf .typedoc/docs && mv .typedoc/temp-docs .typedoc/docs",
+"typedoc:generate:skip-build": "typedoc --tsconfig tsconfig.typedoc.json && node .typedoc/extract-returns-and-params.mjs && rimraf .typedoc/docs && cpy \".typedoc/temp-docs/**\" .typedoc/docs --parents && rimraf .typedoc/temp-docs",
packages/shared/src/react/hooks/useReverification.ts (1)

77-86: Remove | undefined from the Fetcher constraint (previously flagged as critical).

While the fetcher parameter is now correctly bound to the generic, the constraint still permits undefined as a valid Fetcher type. This degrades type inference, allows invalid call sites, and produces incorrect TypeDoc output.

-type UseReverification = <Fetcher extends (...args: any[]) => Promise<any> | undefined>(
+type UseReverification = <Fetcher extends (...args: any[]) => Promise<any>>(
   /**
    * A function that returns a promise.
    */
   fetcher: Fetcher,
   /**
    * The optional options object.
    */
   options?: UseReverificationOptions,
 ) => UseReverificationResult<Fetcher>;
🧹 Nitpick comments (1)
packages/shared/src/react/hooks/useReverification.ts (1)

37-50: Consider readonly modifiers and optional property syntax for immutable callback parameters.

The type is correctly documented for TypeDoc. For stronger immutability guarantees and clearer semantics, consider making the callback functions readonly and using optional property syntax for level.

 export type NeedsReverificationParameters = {
   /**
    * Marks the reverification process as cancelled and rejects the original request.
    */
-  cancel: () => void;
+  readonly cancel: () => void;
   /**
    * Marks the reverification process as complete and retries the original request.
    */
-  complete: () => void;
+  readonly complete: () => void;
   /**
    * The verification level required for the reverification process.
    */
-  level: SessionVerificationLevel | undefined;
+  readonly level?: SessionVerificationLevel;
 };

As per coding guidelines

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9df0c27 and c0b8e19.

📒 Files selected for processing (2)
  • package.json (1 hunks)
  • packages/shared/src/react/hooks/useReverification.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • package.json
  • packages/shared/src/react/hooks/useReverification.ts
**/*.{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/shared/src/react/hooks/useReverification.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/shared/src/react/hooks/useReverification.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/shared/src/react/hooks/useReverification.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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for 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
Use const assertions for literal types: as const
Use satisfies operator 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for 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/shared/src/react/hooks/useReverification.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/shared/src/react/hooks/useReverification.ts
🧬 Code graph analysis (1)
packages/shared/src/react/hooks/useReverification.ts (1)
packages/types/src/sessionVerification.ts (1)
  • SessionVerificationLevel (50-50)
⏰ 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). (27)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (18, --filter=@clerk/astro --filter=@clerk/backend --filter=@clerk/express --filter=@c...
  • GitHub Check: Static analysis
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (2)
.typedoc/custom-plugin.mjs (2)

21-36: FILES_WITHOUT_HEADINGS updates look good; past typo fixed.

Nice cleanup and coverage expansion. Consider a tiny hardening to prevent future duplicates/typos:

  • Use a Set for membership checks.
  • Optionally assert all entries end with ".mdx" and log a warning if not.

Example (optional):
const FILES_WITHOUT_HEADINGS_SET = new Set(FILES_WITHOUT_HEADINGS);

if (fileName && FILES_WITHOUT_HEADINGS_SET.has(fileName)) { … }


46-49: Avoid potential “double-anchor” links for in-page targets.

These newPaths start with "#". If the original MDX link already had an anchor (rare but possible), the current replacement would yield "#foo#bar". Safeguard in getRelativeLinkReplacements by dropping the preserved anchor when newPath starts with "#":

-      replace: (/** @type {string} */ _match, anchor = '') => `(${newPath}${anchor})`,
+      replace: (/** @type {string} */ _match, anchor = '') =>
+        `(${newPath}${newPath.startsWith('#') ? '' : anchor})`,
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c0b8e19 and 32a4c45.

📒 Files selected for processing (2)
  • .typedoc/custom-plugin.mjs (3 hunks)
  • packages/shared/src/react/hooks/useSubscription.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{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/shared/src/react/hooks/useSubscription.tsx
**/*.{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/shared/src/react/hooks/useSubscription.tsx
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/shared/src/react/hooks/useSubscription.tsx
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/shared/src/react/hooks/useSubscription.tsx
**/*.{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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for 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
Use const assertions for literal types: as const
Use satisfies operator 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for 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/shared/src/react/hooks/useSubscription.tsx
**/*.{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components

**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components: UserProfile, NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...

Files:

  • packages/shared/src/react/hooks/useSubscription.tsx
**/*.{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/shared/src/react/hooks/useSubscription.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

**/*.tsx: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering

Files:

  • packages/shared/src/react/hooks/useSubscription.tsx
🧬 Code graph analysis (1)
packages/shared/src/react/hooks/useSubscription.tsx (3)
packages/types/src/billing.ts (2)
  • ForPayerType (69-69)
  • BillingSubscriptionResource (560-610)
packages/clerk-js/src/ui/contexts/components/Plans.tsx (1)
  • useSubscription (63-78)
packages/shared/src/react/hooks/index.ts (1)
  • useSubscription (15-15)
⏰ 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: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
packages/shared/src/react/hooks/useSubscription.tsx (3)

1-1: LGTM! Import correctly added for new return type.

The BillingSubscriptionResource import is necessary for the new UseSubscriptionReturn type definition and is properly sourced from @clerk/types.


15-31: Well-documented parameter type.

The UseSubscriptionParams type is properly structured with clear JSDoc comments that document default values and include helpful context about layout stability.


65-113: Excellent function declaration for TypeDoc.

The change from arrow function to named function declaration with an explicit return type is well-suited for TypeDoc documentation generation. The implementation correctly maps SWR properties to the documented return type.

.typedoc/custom-plugin.mjs (1)

82-94: New absolute replacements LGTM; please verify targets exist.

The billing and error type links look correct. Please validate these endpoints resolve in your local docs build or prod to avoid regressions, especially the returns anchor for use-checkout.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (2)
packages/shared/src/react/hooks/useSubscription.tsx (2)

15-31: Verify @interface tag behavior on type aliases.

The @interface tag is typically reserved for actual interface declarations in TypeDoc, not type aliases. While the documentation content is excellent, you may want to verify that TypeDoc processes this tag correctly for type aliases, or consider removing it if it doesn't affect the output.

If the @interface tag doesn't affect TypeDoc's output for type aliases, you can remove it:

-/**
- * @interface
- */
 export type UseSubscriptionParams = {

33-57: Excellent documentation with same @interface note.

The return type documentation is comprehensive and correctly addresses previous feedback:

  • Error type properly uses Error | undefined to match SWR semantics
  • Data property clearly distinguishes between undefined (not loaded) and null (no subscription)
  • All properties have clear, detailed descriptions

Same minor note about the @interface tag applies here—verify it works as intended with type aliases in TypeDoc.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 32a4c45 and db76fb7.

📒 Files selected for processing (1)
  • packages/shared/src/react/hooks/useSubscription.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{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/shared/src/react/hooks/useSubscription.tsx
**/*.{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/shared/src/react/hooks/useSubscription.tsx
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/shared/src/react/hooks/useSubscription.tsx
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/shared/src/react/hooks/useSubscription.tsx
**/*.{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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for 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
Use const assertions for literal types: as const
Use satisfies operator 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for 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/shared/src/react/hooks/useSubscription.tsx
**/*.{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components

**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components: UserProfile, NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...

Files:

  • packages/shared/src/react/hooks/useSubscription.tsx
**/*.{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/shared/src/react/hooks/useSubscription.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

**/*.tsx: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering

Files:

  • packages/shared/src/react/hooks/useSubscription.tsx
🧬 Code graph analysis (1)
packages/shared/src/react/hooks/useSubscription.tsx (3)
packages/types/src/billing.ts (2)
  • ForPayerType (69-69)
  • BillingSubscriptionResource (560-610)
packages/clerk-js/src/ui/contexts/components/Plans.tsx (1)
  • useSubscription (63-78)
packages/shared/src/react/hooks/index.ts (1)
  • useSubscription (15-15)
⏰ 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). (4)
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
packages/shared/src/react/hooks/useSubscription.tsx (1)

59-113: LGTM! Well-structured implementation with proper typing.

The function implementation is excellent:

  • Explicit return type UseSubscriptionReturn improves type safety and IDE support
  • The revalidate function is properly memoized and exposes manual revalidation capability
  • All return properties match the documented type
  • The @experimental tag appropriately flags this beta feature

The conversion from arrow function to named function export with explicit typing aligns well with the PR's goal of improving TypeDoc output.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

♻️ Duplicate comments (1)
packages/shared/src/react/hooks/useReverification.ts (1)

77-86: Remove | undefined from the Fetcher constraint.

The constraint Fetcher extends (...args: any[]) => Promise<any> | undefined allows fetchers that return undefined directly, but the implementation expects a function returning a Promise. This misleads callers and weakens type safety.

Apply this diff:

-type UseReverification = <Fetcher extends (...args: any[]) => Promise<any> | undefined>(
+type UseReverification = <Fetcher extends (...args: any[]) => Promise<any>>(
   /**
    * A function that returns a promise.
    */
   fetcher: Fetcher,
   /**
    * The optional options object.
    */
   options?: UseReverificationOptions,
 ) => UseReverificationResult<Fetcher>;

Also update the constraint on line 70 for consistency:

-type UseReverificationResult<Fetcher extends (...args: any[]) => Promise<any> | undefined> = (
+type UseReverificationResult<Fetcher extends (...args: any[]) => Promise<any>> = (
   ...args: Parameters<Fetcher>
 ) => Promise<ExcludeClerkError<Awaited<ReturnType<Fetcher>>>>;
🧹 Nitpick comments (1)
packages/shared/src/react/hooks/useReverification.ts (1)

37-50: Consider using readonly fields and optional property syntax for type safety.

While the current implementation is functional, consider these refinements for improved type safety and TypeScript idioms:

  • Mark cancel, complete, and level as readonly to prevent accidental mutation by consumers
  • Use optional property syntax level?: SessionVerificationLevel instead of level: SessionVerificationLevel | undefined for more idiomatic TypeScript

Apply this diff:

 export type NeedsReverificationParameters = {
   /**
    * Marks the reverification process as cancelled and rejects the original request.
    */
-  cancel: () => void;
+  readonly cancel: () => void;
   /**
    * Marks the reverification process as complete and retries the original request.
    */
-  complete: () => void;
+  readonly complete: () => void;
   /**
    * The verification level required for the reverification process.
    */
-  level: SessionVerificationLevel | undefined;
+  readonly level?: SessionVerificationLevel;
 };
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9ff65e9 and a8c4ada.

📒 Files selected for processing (1)
  • packages/shared/src/react/hooks/useReverification.ts (2 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/shared/src/react/hooks/useReverification.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/shared/src/react/hooks/useReverification.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/shared/src/react/hooks/useReverification.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/shared/src/react/hooks/useReverification.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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for 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
Use const assertions for literal types: as const
Use satisfies operator 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for 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/shared/src/react/hooks/useReverification.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/shared/src/react/hooks/useReverification.ts
🧬 Code graph analysis (1)
packages/shared/src/react/hooks/useReverification.ts (1)
packages/types/src/sessionVerification.ts (1)
  • SessionVerificationLevel (50-50)
⏰ 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: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (2)
packages/shared/src/react/hooks/useReverification.ts (2)

55-65: LGTM — Proper JSDoc with nested parameter documentation.

The type export and JSDoc correctly document the onNeedsReverification callback with nested field descriptions, which will generate accurate TypeDoc output.


70-72: Verify whether UseReverificationResult should be exported.

The PR objectives emphasize exposing typed metadata (return types and parameters) via TypeDoc. UseReverificationResult represents the hook's return type but isn't currently exported.

Should this type be exported to provide complete public API documentation, similar to NeedsReverificationParameters and UseReverificationOptions?

@blacksmith-sh
Copy link

blacksmith-sh bot commented Oct 30, 2025

Found 3 test failures on Blacksmith runners:

Test View Logs
[chrome] › integration/tests/
dynamic-keys.test.ts:92:7 › dynamic keys @nextjs › calls clerkClient with dynamic key
s from middleware runtime
View Logs
[chrome] › integration/tests/
session-tasks-multi-session.test.ts:33:9 › session tasks multi-session flow @nextjs › l
ong-running--next.appRouter.withSessionTasks › when switching sessions, navigate to tas
k
View Logs
[setup] › integration/tests/
global.setup.ts:7:6 › start long running apps ─────────────────────
View Logs


Fix in Cursor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants