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

    • Stronger public TypeScript types across payments, checkout, subscription, plans, and paginated hooks; useSubscription now exposes a revalidate helper.
  • Documentation

    • Expanded JSDoc and reference docs for payments, checkout, reverification, subscriptions and hooks; improved typedoc extraction and internal link handling for richer reference pages.
  • Chores

    • Reorganized exported typings and public surface (non-functional); no runtime behavior changes.

@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 Nov 4, 2025 4:03pm

@changeset-bot
Copy link

changeset-bot bot commented Oct 1, 2025

🦋 Changeset detected

Latest commit: 6afd559

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

Promotes many internal TypeScript types to exported public API types with JSDoc, updates several hook signatures to reference those types, adds a Typedoc post-processing script to split "Returns" and "Parameters" into separate MDX files, and adjusts Typedoc config and scripts. No runtime logic changes.

Changes

Cohort / File(s) Summary
Commerce types
packages/shared/src/react/commerce.tsx
Export new public types: PaymentElementProviderProps, PaymentElementProps, and UsePaymentElementReturn; add JSDoc and update PaymentElement props to use PaymentElementProps. No runtime logic changes.
Checkout types & hook
packages/shared/src/react/contexts.tsx, packages/shared/src/react/hooks/useCheckout.ts
Export UseCheckoutOptions; add UseCheckoutReturn and UseCheckoutParams (renamed from Params); update useCheckout signature to accept UseCheckoutParams and have the new typed return; add JSDoc.
Reverification hook types
packages/shared/src/react/hooks/useReverification.ts
Export NeedsReverificationParameters and UseReverificationOptions; add JSDoc and document UseReverification parameters. No runtime changes.
Subscription & billing hooks
packages/shared/src/react/hooks/useSubscription.tsx, packages/shared/src/react/hooks/usePlans.tsx, packages/shared/src/react/hooks/createBillingPaginatedHook.tsx
Export UseSubscriptionParams, UseSubscriptionReturn, and UsePlansReturn; export HookParams interface; update useSubscription return type to UseSubscriptionReturn and include revalidate; add JSDoc and import BillingSubscriptionResource.
Error docs
packages/shared/src/errors/clerkApiResponseError.ts
Add JSDoc for ClerkAPIResponseError class. No behavior change.
Typedoc extraction script
.typedoc/extract-returns-and-params.mjs
New Node script that scans generated MDX files, extracts "## Returns" → *-return.mdx and "## Parameters" → *-params.mdx, replaces a generic type pattern in params tables, deletes stale *-props.mdx, and logs outputs.
Typedoc plugin config
.typedoc/custom-plugin.mjs
Remove duplicate entry, expand FILES_WITHOUT_HEADINGS, and add new LINK_REPLACEMENTS mappings (e.g., use-checkout-options, needs-reverification-parameters, billing resources).
Build script
package.json
Insert node .typedoc/extract-returns-and-params.mjs into typedoc:generate:skip-build script between TypeDoc run and cleanup/move steps.
Typedoc entryPoints
packages/shared/typedoc.json
Add new entryPoints: ./src/react/commerce.tsx, ./src/react/contexts.tsx, and ./src/types/*.{ts,tsx}.
Release metadata
.changeset/violet-boxes-watch.md
Add changeset file indicating minor bumps and note about ensuring hooks use Typedoc.

Sequence Diagram(s)

sequenceDiagram
    participant CI as Build/CI
    participant TypeDoc as TypeDoc
    participant Temp as .typedoc/temp-docs (MDX)
    participant Extractor as extract-returns-and-params.mjs
    participant Docs as .typedoc/docs (Output)

    CI->>TypeDoc: Run TypeDoc (tsconfig.typedoc.json)
    TypeDoc->>Temp: Emit MDX files

    CI->>Extractor: Run extractor script
    Extractor->>Temp: Read MDX files
    Extractor->>Temp: Extract "## Returns" -> write *-return.mdx
    Extractor->>Temp: Extract "## Parameters" -> write *-params.mdx
    Extractor->>Temp: Delete stale *-props.mdx
    Note over Extractor,Temp: Replace generic type tables and update param typing

    CI->>CI: Cleanup & move temp docs
    CI->>Docs: Move .typedoc/temp-docs -> .typedoc/docs
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas to focus on:
    • .typedoc/extract-returns-and-params.mjs — file traversal, extraction bounds, regex replacement correctness, and safe deletion of *-props.mdx.
    • useCheckout / UseCheckoutReturn — ensure exported type matches runtime return shape and preserves backward compatibility.
    • useReverification types — verify the new exported types don't break consumer call sites or inference.
    • useSubscription — confirm revalidate is present and UseSubscriptionReturn aligns with implementation.
    • custom-plugin.mjs link mappings — validate anchors match generated headings.

🐇✨
Types hopped out into the light,
Docs trimmed tidy, sections split right.
Returns and params now neatly stored,
Hooks wear JSDoc like a carrot sword.
A rabbit cheers — the code feels light!

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: generating params and return types for hooks using Typedoc documentation.
Linked Issues check ✅ Passed The PR successfully addresses DOCS-10983 by adding JSDoc comments to hooks, exporting public types for hook params and returns, and setting up Typedoc to generate documentation for these types.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the DOCS-10983 objective of ensuring hooks use Typedoc for params and returns; configuration, type exports, and documentation updates align with stated goals.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ss/DOCS-10983

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

🧹 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

This comment has been minimized.

Fetcher extends (...args: any[]) => Promise<any> | undefined,
Options extends UseReverificationOptions = UseReverificationOptions,
>(
type UseReverification = <Fetcher extends (...args: any[]) => Promise<any> | undefined>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing the second generic type from this type will break anything that expects it to be there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm. Yeah I removed it cause it appeared like this on the docs.

Screenshot 2025-11-03 at 12 10 49 pm

Copy link
Contributor

Choose a reason for hiding this comment

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

I recon the description of the parameter should be better, but not changing the signature of the type is more important than a not perfect typedoc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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)

204-204: Fix typo in code example.

The comment contains a grammatical error.

Apply this diff:

-      //     ^ is types as `MyData`
+      //     ^ is typed as `MyData`
🧹 Nitpick comments (2)
packages/shared/src/react/hooks/useReverification.ts (2)

14-16: Remove the empty JSDoc block.

This empty comment block was flagged in a previous review and marked as fixed, but it remains. Since resolveResult is an internal function, either remove the comment or add a meaningful description.

Apply this diff to remove the empty block:

-/**
- *
- */
 async function resolveResult<T>(result: Promise<T> | T): Promise<T | ReturnType<typeof reverificationError>> {

100-102: Remove the empty JSDoc block.

This empty comment was also flagged previously and marked as fixed, but remains. Since createReverificationHandler is internal, either remove the comment or document its purpose.

Apply this diff:

-/**
- *
- */
 function createReverificationHandler(params: CreateReverificationHandlerParams) {
📜 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 3029aa3 and 623e24b.

📒 Files selected for processing (2)
  • .typedoc/custom-plugin.mjs (3 hunks)
  • packages/shared/src/react/hooks/useReverification.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .typedoc/custom-plugin.mjs
🧰 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
⏰ 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/useReverification.ts (2)

40-53: LGTM!

The JSDoc descriptions are now correct and well-documented for TypeDoc extraction.


60-70: LGTM!

The nested parameter documentation correctly describes the properties object and its fields for TypeDoc.

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)

14-16: Remove empty JSDoc comment.

This empty JSDoc block adds no value. Per past review feedback, these were marked for cleanup but remain in the code.

Apply this diff:

-/**
- *
- */
 async function resolveResult<T>(result: Promise<T> | T): Promise<T | ReturnType<typeof reverificationError>> {
♻️ Duplicate comments (1)
packages/shared/src/react/hooks/useReverification.ts (1)

101-107: Remove empty JSDoc comments.

Multiple empty JSDoc blocks (lines 101-103, 105-107) add no value. Per past review feedback, these were marked for cleanup but remain in the code.

Apply this diff:

-/**
- *
- */
 function createReverificationHandler(params: CreateReverificationHandlerParams) {
-  /**
-   *
-   */
   function assertReverification<Fetcher extends (...args: any[]) => Promise<any> | undefined>(
🧹 Nitpick comments (1)
packages/shared/src/react/hooks/useReverification.ts (1)

40-53: Consider readonly and optional property syntax for type safety.

The JSDoc documentation is accurate. For improved type safety and TypeScript best practices:

  • Mark callback fields as readonly to prevent reassignment
  • Use optional syntax level?: SessionVerificationLevel instead of | undefined for clarity

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 b6e0a0e and 7c7ddb6.

📒 Files selected for processing (2)
  • packages/shared/src/react/hooks/useReverification.ts (3 hunks)
  • packages/shared/src/react/hooks/useSubscription.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/shared/src/react/hooks/useSubscription.tsx
🧰 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
⏰ 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)

60-70: LGTM!

The JSDoc documentation for UseReverificationOptions correctly describes the properties object with nested parameter documentation. This should generate accurate TypeDoc output.


82-94: Inline JSDoc is clear and the | undefined constraint is correct.

The | undefined in the Fetcher constraint intentionally allows fetchers whose return types can be Promise<X> | undefined due to optional chaining (e.g., () => user?.createTOTP()). This pattern is used throughout the codebase. The resolveResult function properly handles undefined returns since it accepts Promise<T> | T. The inline JSDoc for both parameters is clear and follows the established documentation style.

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