Skip to content

Conversation

@nikosdouvlis
Copy link
Member

@nikosdouvlis nikosdouvlis commented Oct 14, 2025

Description

Tiny cleanup in preparation for #6906

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

    • Exposes types via new public subpaths and adds a small exported mock type for testing.
    • Enhances error payload types with richer metadata (messages, params, session info, plan details, suggestions).
  • Refactor

    • Adjusts public exports to surface consolidated error types instead of the previous API re-exports.
  • Chores

    • Includes type files in the build/published package.
    • Adds a placeholder changeset entry.

@changeset-bot
Copy link

changeset-bot bot commented Oct 14, 2025

🦋 Changeset detected

Latest commit: 98b8f04

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

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

@vercel
Copy link

vercel bot commented Oct 14, 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 14, 2025 9:41am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 14, 2025

Walkthrough

Adds a placeholder changeset and publishes type declarations from the shared package; expands build/subpath rules to include a types folder. Centralizes Clerk API error types by adding ClerkAPIErrorJSON in packages/types, re-exporting errors, and updating imports across types files.

Changes

Cohort / File(s) Summary of Changes
Repo meta
./.changeset/dull-news-live.md
Added a placeholder changeset file containing only delimiter lines.
Shared package exports & build
packages/shared/package.json, packages/shared/subpaths.mjs, packages/shared/tsup.config.ts
Exposed ./types in exports (root and ./dom), added "types" to files, appended types to subpath barrel list, and added ./src/types/*.ts to tsup entries.
Types package: error model & re-exports
packages/types/src/errors.ts, packages/types/src/index.ts, packages/types/src/json.ts, packages/types/src/verification.ts, packages/types/src/clerk.ts
Introduced ClerkAPIErrorJSON in errors.ts; replaced export * from './api' with export * from './errors' in index.ts; updated imports to source error types from ./errors; json.ts now imports ClerkAPIErrorJSON instead of declaring it locally.
Shared types export
packages/shared/src/types/index.ts
Added exported type alias export type _unstable_mock_type = any;.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I hop through code with tidy paws,
Moved errors into neat little laws.
Types appear where bulbs once slept,
Exports bloom — the burrow’s prepped.
A tiny stamp, a joyful hop, and off I bound! 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title concisely captures the main work of the PR—relocating error-related types to errors.ts within the types and shared packages—and uses a clear conventional-commit style that aligns with the changeset and objectives.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ 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 nikos/userland-errors-p5

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 14, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6984

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6984

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6984

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6984

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6984

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6984

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6984

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6984

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6984

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6984

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6984

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6984

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6984

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6984

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6984

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6984

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6984

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6984

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6984

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6984

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6984

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6984

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6984

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6984

commit: 98b8f04

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: 2

🧹 Nitpick comments (4)
.changeset/dull-news-live.md (1)

1-2: Fill the changeset with package bumps and summary

This placeholder won’t publish. Add affected packages and semver bumps (at least @clerk/shared, @clerk/types) and a short note, e.g.:

---
'@clerk/shared': patch
'@clerk/types': patch
---

chore(types,shared): centralize error-related types in errors.ts and expose shared ./types subpath

If removing './api' exports is user-facing, consider a breaking note and a major bump.

packages/shared/tsup.config.ts (1)

19-19: Include './src/types/*.ts' in build — LGTM

This will emit declarations for the new subpath. If these files are type-only, consider marking exports as export type to minimize runtime output; not blocking.

packages/types/src/errors.ts (2)

1-25: Add JSDoc and mark collection fields readonly on public JSON type

This is a public surface; add brief JSDoc and use readonly for arrays to reflect immutability of API payloads.

Apply:

+/**
+ * JSON wire shape of a Clerk API error as returned by the HTTP API.
+ * Note: keys follow snake_case to match the API.
+ */
 export interface ClerkAPIErrorJSON {
   code: string;
   message: string;
   long_message?: string;
   meta?: {
     param_name?: string;
     session_id?: string;
-    email_addresses?: string[];
-    identifiers?: string[];
+    email_addresses?: readonly string[];
+    identifiers?: readonly string[];
     zxcvbn?: {
-      suggestions: {
+      suggestions: readonly {
         code: string;
         message: string;
       }[];
     };
     plan?: {
       amount_formatted: string;
       annual_monthly_amount_formatted: string;
       currency_symbol: string;
       id: string;
       name: string;
     };
     is_plan_upgrade_possible?: boolean;
   };
 }

77-83: Clarify units for retryAfter and document status

Add brief JSDoc for HTTP status and whether retryAfter is seconds or milliseconds.

Example:

 export interface ClerkAPIResponseError extends Error {
   clerkError: true;
-  status: number;
-  message: string;
+  /** HTTP status code of the response (e.g., 429, 500). */
+  status: number;
+  message: string;
   clerkTraceId?: string;
-  retryAfter?: number;
+  /** Backoff duration as returned by the API (e.g., seconds from Retry-After header). */
+  retryAfter?: number;
   errors: ClerkAPIError[];
 }
📜 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 14753fc and 1ad8ee0.

📒 Files selected for processing (9)
  • .changeset/dull-news-live.md (1 hunks)
  • packages/shared/package.json (2 hunks)
  • packages/shared/subpaths.mjs (1 hunks)
  • packages/shared/tsup.config.ts (1 hunks)
  • packages/types/src/clerk.ts (1 hunks)
  • packages/types/src/errors.ts (1 hunks)
  • packages/types/src/index.ts (1 hunks)
  • packages/types/src/json.ts (1 hunks)
  • packages/types/src/verification.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (11)
**/*.{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/tsup.config.ts
  • packages/types/src/errors.ts
  • packages/types/src/clerk.ts
  • packages/types/src/json.ts
  • packages/types/src/index.ts
  • packages/types/src/verification.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/tsup.config.ts
  • packages/types/src/errors.ts
  • packages/types/src/clerk.ts
  • packages/types/src/json.ts
  • packages/types/src/index.ts
  • packages/types/src/verification.ts
  • packages/shared/package.json
packages/**/*.{ts,tsx}

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

TypeScript is required for all packages

Files:

  • packages/shared/tsup.config.ts
  • packages/types/src/errors.ts
  • packages/types/src/clerk.ts
  • packages/types/src/json.ts
  • packages/types/src/index.ts
  • packages/types/src/verification.ts
packages/**/*.{ts,tsx,d.ts}

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

Packages should export TypeScript types alongside runtime code

Files:

  • packages/shared/tsup.config.ts
  • packages/types/src/errors.ts
  • packages/types/src/clerk.ts
  • packages/types/src/json.ts
  • packages/types/src/index.ts
  • packages/types/src/verification.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/tsup.config.ts
  • packages/types/src/errors.ts
  • packages/types/src/clerk.ts
  • packages/types/src/json.ts
  • packages/types/src/index.ts
  • packages/types/src/verification.ts
packages/*/tsup.config.{js,ts}

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

TypeScript compilation and bundling must use tsup.

Files:

  • packages/shared/tsup.config.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/tsup.config.ts
  • packages/types/src/errors.ts
  • packages/types/src/clerk.ts
  • packages/types/src/json.ts
  • packages/types/src/index.ts
  • packages/types/src/verification.ts
packages/**/index.{js,ts}

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

Use tree-shaking friendly exports

Files:

  • packages/types/src/index.ts
**/index.ts

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

Use index.ts files for clean imports but avoid deep barrel exports

Avoid barrel files (index.ts re-exports) as they can cause circular dependencies

Files:

  • packages/types/src/index.ts
.changeset/**

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

Automated releases must use Changesets.

Files:

  • .changeset/dull-news-live.md
packages/*/package.json

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

All publishable packages should be placed under the packages/ directory

packages/*/package.json: All publishable packages must be located in the 'packages/' directory.
All packages must be published under the @clerk namespace on npm.
Semantic versioning must be used across all packages.

Files:

  • packages/shared/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: 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 (5)
packages/shared/subpaths.mjs (1)

10-10: Add 'types' to barrel subpaths — LGTM

Matches package.json/files and the new export. No issues.

packages/types/src/json.ts (1)

18-18: Centralize ClerkAPIErrorJSON import — LGTM

Ensure the ClerkAPIErrorJSON interface in errors.ts includes all fields returned by the Clerk API’s error payload.

packages/types/src/clerk.ts (1)

34-34: Confirm ClerkAPIResponseError export
ClerkAPIResponseError is explicitly exported from errors.ts and re-exported in index.ts; import path './errors' is correct.

packages/types/src/index.ts (1)

20-20: Remove incorrect “./api” BC warning
No packages/types/src/api.ts exists and export * from './api' was never present—this concern is invalid.

Likely an incorrect or invalid review comment.

packages/types/src/verification.ts (1)

1-1: LGTM — type-only import move
Importing ClerkAPIError from './errors' keeps value emissions out of the bundle; no lingering imports/re-exports from './api' and errors are properly re-exported.

Comment on lines +73 to +80
"./types": {
"import": {
"types": "./dist/types/index.d.mts"
},
"require": {
"types": "./dist/types/index.d.ts"
}
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

New "./types" export: verify packaging and declaration output

Looks good and consistent with existing pattern. Please verify:

  • dist/types/index.d.mts and index.d.ts are emitted by the build.
  • publint/attw are clean for the new subpath.

Suggested commands:

Also consider whether a wildcard subpath (e.g. "./types/*") is desired in the future for granular imports. Not required now.

Also applies to: 134-136


🏁 Script executed:

#!/bin/bash
# Check that type entrypoints are emitted (after a local build)
fd -p 'index.d.(mts|ts)$' dist/types -E node_modules

# Sanity-check subpath exports reference the emitted files
jq '.exports["./types"]' packages/shared/package.json

# Run packaging linters (locally)
echo "In your env, run:"
echo "pnpm -w --filter @clerk/shared build && pnpm -w --filter @clerk/shared lint:publint && pnpm -w --filter @clerk/shared lint:attw"

Length of output: 364


🏁 Script executed:

#!/bin/bash
if [ -d packages/shared/dist/types ]; then
  echo "✅ Directory packages/shared/dist/types exists"
  fd -p 'index.d.(mts|ts)$' packages/shared/dist/types
else
  echo "🚨 Directory packages/shared/dist/types is missing"
fi

Length of output: 50


Exported ./types subpath files not found

The directory packages/shared/dist/types (with index.d.mts and index.d.ts) is missing, so the new "./types" export will break. Ensure your build generates those declaration files under dist/types before publishing.

🤖 Prompt for AI Agents
In packages/shared/package.json around lines 73 to 80, the new "./types" export
points to dist/types/index.d.mts and dist/types/index.d.ts which do not exist;
update the build to emit declaration files into dist/types (or change the export
to match actual paths). Modify tsconfig/build config to set "declaration": true
and "declarationDir": "dist/types" (or adjust your bundler) so index.d.ts/.d.mts
are generated during build, then ensure the build step runs before publishing
and verify the files exist in dist/types.

Comment on lines +1 to +25
export interface ClerkAPIErrorJSON {
code: string;
message: string;
long_message?: string;
meta?: {
param_name?: string;
session_id?: string;
email_addresses?: string[];
identifiers?: string[];
zxcvbn?: {
suggestions: {
code: string;
message: string;
}[];
};
plan?: {
amount_formatted: string;
annual_monthly_amount_formatted: string;
currency_symbol: string;
id: string;
name: string;
};
is_plan_upgrade_possible?: boolean;
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Align JSON vs runtime error meta shape (plan naming, permissions parity)

  • Runtime ClerkAPIError.meta uses camelCase, but plan fields remain snake_case; this is inconsistent with the rest of the runtime shape. Either:
    • keep ClerkAPIErrorJSON as the only snake_case type and expose ClerkAPIError.plan with camelCase (document the mapping), or
    • add a comment clarifying that plan is intentionally snake_case in runtime.
  • Also, runtime meta includes permissions?: string[] but JSON meta does not. If the API returns it, mirror it in ClerkAPIErrorJSON; otherwise document the divergence.

Run to locate other references and confirm intended shape:

Also applies to: 58-65


🏁 Script executed:

#!/bin/bash
# Inspect other occurrences of plan fields and permissions across types
rg -nP -C3 --type=ts '\b(plan|permissions)\b.*:'

Length of output: 139607


🏁 Script executed:

#!/bin/bash
# Display the beginning of the errors.ts to inspect ClerkAPIErrorJSON
sed -n '1,80p' packages/types/src/errors.ts
# Display the continuation to show runtime meta shape
sed -n '80,140p' packages/types/src/errors.ts

Length of output: 1774


Align ClerkAPIErrorJSON & ClerkAPIError.meta (add permissions + unify plan field casing)

  • In packages/types/src/errors.ts, add permissions?: string[] to ClerkAPIErrorJSON.meta
  • Rename plan props in both ClerkAPIErrorJSON.meta.plan and ClerkAPIError.meta.plan to camelCase (amountFormatted, annualMonthlyAmountFormatted, currencySymbol) and update the mapping in parseError.ts accordingly
🤖 Prompt for AI Agents
In packages/types/src/errors.ts around lines 1 to 25, the ClerkAPIErrorJSON.meta
shape needs to include an optional permissions?: string[] field and the nested
plan property keys must be converted from snake/slug/case to camelCase
(amountFormatted, annualMonthlyAmountFormatted, currencySymbol) to match
ClerkAPIError.meta; update the interface accordingly and then modify
parseError.ts mappings to translate incoming API plan fields to these new
camelCase property names (and ensure both the JSON type and the internal
ClerkAPIError.meta plan type use the same camelCase keys).

@nikosdouvlis nikosdouvlis changed the title chore(typed,shared): Move error related types to errors.ts chore(types,shared): Move error related types to errors.ts Oct 14, 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: 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 1ad8ee0 and 98b8f04.

📒 Files selected for processing (3)
  • .changeset/dull-news-live.md (1 hunks)
  • packages/shared/src/types/index.ts (1 hunks)
  • packages/types/src/clerk.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{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/types/index.ts
  • packages/types/src/clerk.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

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

Use Prettier for consistent code formatting

Files:

  • packages/shared/src/types/index.ts
  • packages/types/src/clerk.ts
packages/**/*.{ts,tsx}

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

TypeScript is required for all packages

Files:

  • packages/shared/src/types/index.ts
  • packages/types/src/clerk.ts
packages/**/*.{ts,tsx,d.ts}

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

Packages should export TypeScript types alongside runtime code

Files:

  • packages/shared/src/types/index.ts
  • packages/types/src/clerk.ts
packages/**/index.{js,ts}

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

Use tree-shaking friendly exports

Files:

  • packages/shared/src/types/index.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/types/index.ts
  • packages/types/src/clerk.ts
**/*.{js,ts,tsx,jsx}

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

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/shared/src/types/index.ts
  • packages/types/src/clerk.ts
**/index.ts

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

Use index.ts files for clean imports but avoid deep barrel exports

Avoid barrel files (index.ts re-exports) as they can cause circular dependencies

Files:

  • packages/shared/src/types/index.ts
.changeset/**

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

Automated releases must use Changesets.

Files:

  • .changeset/dull-news-live.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (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)
.changeset/dull-news-live.md (1)

1-2: Add meaningful changeset description before merging.

This changeset is currently a placeholder. Please add a description of the changes (moving error-related types to errors.ts) and specify the appropriate semver bump type (likely patch for this refactoring).

packages/types/src/clerk.ts (1)

34-34: All ClerkAPIResponseError imports updated

No remaining imports from './api'; all references now import from './errors'.

@@ -0,0 +1 @@
export type _unstable_mock_type = any;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Replace any with unknown or provide justification.

The use of any violates TypeScript best practices and defeats type safety guarantees. Additionally, this public type export lacks JSDoc documentation explaining its purpose and usage.

As per coding guidelines:

  • "Avoid any type - prefer unknown when type is uncertain"
  • "All public APIs must be documented with JSDoc"

Consider this refactor:

+/**
+ * Unstable mock type for testing purposes.
+ * @experimental This type is unstable and may change in future versions.
+ */
-export type _unstable_mock_type = any;
+export type _unstable_mock_type = unknown;

If any is truly required for mocking scenarios, please add JSDoc explaining why and provide usage examples.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export type _unstable_mock_type = any;
/**
* Unstable mock type for testing purposes.
* @experimental This type is unstable and may change in future versions.
*/
export type _unstable_mock_type = unknown;
🤖 Prompt for AI Agents
In packages/shared/src/types/index.ts around line 1, the exported type
_unstable_mock_type currently uses `any`, which breaks type safety and lacks
documentation; replace `any` with `unknown` (or a more specific generic) and add
JSDoc explaining the type's purpose, usage, and why `unknown` is appropriate, or
if `any` is truly required for mocking, keep `any` but add explicit JSDoc
justification and usage examples showing safe casting/validation patterns.

@nikosdouvlis nikosdouvlis merged commit 7b3231a into main Oct 14, 2025
40 of 41 checks passed
@nikosdouvlis nikosdouvlis deleted the nikos/userland-errors-p5 branch October 14, 2025 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants