-
Notifications
You must be signed in to change notification settings - Fork 402
docs(repo): Generate all params and return types (hooks work) #6901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 6afd559 The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughPromotes 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
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/shared/src/react/hooks/useSubscription.tsx (2)
15-31: Verify@interfacetag behavior on type aliases.The
@interfacetag is typically reserved for actualinterfacedeclarations in TypeDoc, nottypealiases. 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
@interfacetag doesn't affect TypeDoc's output for type aliases, you can remove it:-/** - * @interface - */ export type UseSubscriptionParams = {
33-57: Excellent documentation with same@interfacenote.The return type documentation is comprehensive and correctly addresses previous feedback:
- Error type properly uses
Error | undefinedto match SWR semantics- Data property clearly distinguishes between
undefined(not loaded) andnull(no subscription)- All properties have clear, detailed descriptions
Same minor note about the
@interfacetag 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.
📒 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
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertionsfor literal types:as const
Usesatisfiesoperator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/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
UseSubscriptionReturnimproves type safety and IDE support- The
revalidatefunction is properly memoized and exposes manual revalidation capability- All return properties match the documented type
- The
@experimentaltag appropriately flags this beta featureThe conversion from arrow function to named function export with explicit typing aligns well with the PR's goal of improving TypeDoc output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
packages/shared/src/react/hooks/useReverification.ts (1)
77-86: Remove| undefinedfrom theFetcherconstraint.The constraint
Fetcher extends (...args: any[]) => Promise<any> | undefinedallows fetchers that returnundefineddirectly, but the implementation expects a function returning aPromise. 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 usingreadonlyfields 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, andlevelasreadonlyto prevent accidental mutation by consumers- Use optional property syntax
level?: SessionVerificationLevelinstead oflevel: SessionVerificationLevel | undefinedfor more idiomatic TypeScriptApply 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.
📒 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
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertionsfor literal types:as const
Usesatisfiesoperator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/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
onNeedsReverificationcallback with nested field descriptions, which will generate accurate TypeDoc output.
70-72: Verify whetherUseReverificationResultshould be exported.The PR objectives emphasize exposing typed metadata (return types and parameters) via TypeDoc.
UseReverificationResultrepresents the hook's return type but isn't currently exported.Should this type be exported to provide complete public API documentation, similar to
NeedsReverificationParametersandUseReverificationOptions?
This comment has been minimized.
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>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the second generic type from this type will break anything that expects it to be there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here: Fix useReverification generic parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
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
resolveResultis 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
createReverificationHandleris 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.
📒 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
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertionsfor literal types:as const
Usesatisfiesoperator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/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
propertiesobject and its fields for TypeDoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
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: Considerreadonlyand optional property syntax for type safety.The JSDoc documentation is accurate. For improved type safety and TypeScript best practices:
- Mark callback fields as
readonlyto prevent reassignment- Use optional syntax
level?: SessionVerificationLevelinstead of| undefinedfor clarityApply 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.
📒 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
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertionsfor literal types:as const
Usesatisfiesoperator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/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
UseReverificationOptionscorrectly describes thepropertiesobject with nested parameter documentation. This should generate accurate TypeDoc output.
82-94: Inline JSDoc is clear and the| undefinedconstraint is correct.The
| undefinedin the Fetcher constraint intentionally allows fetchers whose return types can bePromise<X> | undefineddue to optional chaining (e.g.,() => user?.createTOTP()). This pattern is used throughout the codebase. TheresolveResultfunction properly handles undefined returns since it acceptsPromise<T> | T. The inline JSDoc for both parameters is clear and follows the established documentation style.

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:
clerk-docsfor this: https://github.com/clerk/clerk-docs/pull/2649/filesAdditionally, 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:
This PR will be the first in a sequence. Once merged, we’ll proceed with its sibling PR in
clerk-docs,which:Hooks checklist
useAuth,useReverificationand 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:
javascriptrepo, switch to the branch of this PRpnpm run typedoc:generatess/DOCS-10983npm run typedoc:link ../javascript/.typedoc/docsImportant notes/ discussion pts
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
New Features
Documentation
Chores