Skip to content

chore(clerk-js,types): Replace payerType[] with forPayerType #6342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

panteliselef
Copy link
Member

@panteliselef panteliselef commented Jul 17, 2025

Description

Orginially we supported plans to be shared with orgs and users. Prior to launch we changed this behaviour and the payerType array would only include a single item of either org or user. With the recent decision to treat commerce APIs as experimental due to the feature being in Beta, we can completely remove this and use the new forPayerType.

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

  • Refactor
    • Updated billing-related terminology and types from "subscriber" to "payer" for improved clarity and consistency.
    • Simplified payer type specification from an array to a single value, now strictly limited to 'org' or 'user'.
    • Unified property and context names across billing and plan details interfaces for a more streamlined experience.
  • Bug Fixes
    • Improved type safety in plan and billing components to reduce potential errors.

@panteliselef panteliselef requested a review from aeliox July 17, 2025 15:46
@panteliselef panteliselef self-assigned this Jul 17, 2025
Copy link

changeset-bot bot commented Jul 17, 2025

🦋 Changeset detected

Latest commit: 17134ac

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

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

Copy link

vercel bot commented Jul 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2025 7:01pm

Copy link
Contributor

coderabbitai bot commented Jul 17, 2025

📝 Walkthrough

Walkthrough

This change refactors billing-related type definitions and usage across several packages. It replaces the previous array-based payerType property (typed as string[] or payerType[]) with a new property, forPayerType, which is strictly typed as the union 'org' | 'user' via the new CommercePayerType type alias. All references to the old payerType property and the CommerceSubscriberType type are updated to use the new naming and type. This affects type declarations, class properties, React context types, and JSON interfaces, ensuring consistent and strictly-typed payer specification throughout the codebase.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3ce1ea and 78e1cfd.

⛔ Files ignored due to path filters (1)
  • .typedoc/__tests__/__snapshots__/file-structure.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • packages/types/src/json.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/types/src/json.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: semgrep-cloud-platform/scan
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep/ci

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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/types/src/clerk.ts (1)

1805-1811: Property name drift vs. new domain wording.

subscriberType?: CommercePayerType; still carries the legacy subscriber wording, whereas the rest of the PR migrates to payer (forPayerType, etc.).

Staying inconsistent can confuse downstream consumers and future refactors.

-  subscriberType?: CommercePayerType;
+  /**
+   * The payer type this checkout is created for.
+   * Leaving as `subscriberType` for backwards-compat, but consider renaming to
+   * `forPayerType` in the next breaking change.
+   */
+  forPayerType?: CommercePayerType;

If renaming is impractical right now, at least add a JSDoc note indicating the planned deprecation of subscriberType.

packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (1)

5-8: Context rename consideration & minor spelling nit.

The context still lives in SubscriberType.ts, with a constant DEFAUlT (lower-case l).
As the domain language shifts to payer, consider renaming the file + context to PayerType on the next non-trivial change, and fix the typo while you’re there.

No code change required in this PR.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56e014c and a3ce1ea.

📒 Files selected for processing (7)
  • .changeset/proud-pianos-attack.md (1 hunks)
  • packages/clerk-js/src/core/resources/CommercePlan.ts (4 hunks)
  • packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx (1 hunks)
  • packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (1 hunks)
  • packages/types/src/clerk.ts (3 hunks)
  • packages/types/src/commerce.ts (3 hunks)
  • packages/types/src/json.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/development.mdc
packages/**/*.{ts,tsx,d.ts}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/development.mdc
**/*.{ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/development.mdc
  • .cursor/rules/typescript.mdc
**/*.{tsx,jsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/development.mdc
packages/{clerk-js,elements,themes}/**/*

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/monorepo.mdc
**/*.{jsx,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/react.mdc
**/*.tsx

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/react.mdc
**/*

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

packages/**/*.ts

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/development.mdc
🧠 Learnings (8)
📓 Common learnings
Learnt from: dstaley
PR: clerk/javascript#6116
File: .changeset/tangy-garlics-say.md:1-2
Timestamp: 2025-06-13T16:09:53.061Z
Learning: In the Clerk JavaScript repository, contributors create intentionally empty changeset files (containing only the YAML delimiters) when a PR touches only non-published parts of the codebase (e.g., sandbox assets). This signals that no package release is required, so such changesets should not be flagged as missing content.
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use `type` for unions, primitives, and computed types
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper type definitions for props and state
Learnt from: wobsoriano
PR: clerk/javascript#6123
File: packages/nextjs/src/server/__tests__/getAuthDataFromRequest.test.ts:63-75
Timestamp: 2025-06-16T01:27:54.563Z
Learning: In packages/nextjs/src/server/data/getAuthDataFromRequest.ts, the tokenType behavior on mismatch is intentionally different between array and single acceptsToken values: when acceptsToken is an array and the token type doesn't match any in the array, tokenType returns null; when acceptsToken is a single value and the token type doesn't match, tokenType returns the requested single value. This design aligns with developer intent and provides a more ergonomic API for common use cases.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Proper use of utility types instead of manual type construction
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use mapped types for transforming object types
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use immutable update patterns (spread, etc.) for objects and arrays
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Implement proper generic types for reusable components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use branded types for domain safety
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx (3)
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: wobsoriano
PR: clerk/javascript#6123
File: packages/nextjs/src/server/__tests__/getAuthDataFromRequest.test.ts:63-75
Timestamp: 2025-06-16T01:27:54.563Z
Learning: In packages/nextjs/src/server/data/getAuthDataFromRequest.ts, the tokenType behavior on mismatch is intentionally different between array and single acceptsToken values: when acceptsToken is an array and the token type doesn't match any in the array, tokenType returns null; when acceptsToken is a single value and the token type doesn't match, tokenType returns the requested single value. This design aligns with developer intent and provides a more ergonomic API for common use cases.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper type definitions for props and state
.changeset/proud-pianos-attack.md (14)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use `type` for unions, primitives, and computed types
Learnt from: panteliselef
PR: clerk/javascript#6327
File: .changeset/eight-socks-lead.md:2-4
Timestamp: 2025-07-16T10:43:17.706Z
Learning: In the Clerk JavaScript repository, APIs marked with @experimental JSDoc annotations can have breaking changes released with minor version bumps rather than major version bumps, as consumers are warned about the instability of experimental features. The billing feature specifically has an @experimental annotation stating "This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change."
Learnt from: LauraBeatris
PR: clerk/javascript#6273
File: packages/testing/src/playwright/unstable/page-objects/sessionTask.ts:22-27
Timestamp: 2025-07-11T17:12:28.495Z
Learning: In Clerk's test utilities, particularly for page objects like sessionTask.ts, when handling task type enums, prefer graceful handling of unknown/unsupported task types rather than throwing errors. This prevents breaking existing tests when new task types are introduced to the SessionTask['key'] union type.
Learnt from: dstaley
PR: clerk/javascript#6116
File: .changeset/tangy-garlics-say.md:1-2
Timestamp: 2025-06-13T16:09:53.061Z
Learning: In the Clerk JavaScript repository, contributors create intentionally empty changeset files (containing only the YAML delimiters) when a PR touches only non-published parts of the codebase (e.g., sandbox assets). This signals that no package release is required, so such changesets should not be flagged as missing content.
Learnt from: wobsoriano
PR: clerk/javascript#6229
File: packages/backend/src/api/endpoints/MachineTokensApi.ts:47-89
Timestamp: 2025-07-01T15:20:41.834Z
Learning: In the Clerk JavaScript repository, for the MachineTokensApi class (packages/backend/src/api/endpoints/MachineTokensApi.ts), the maintainers prefer to rely on TypeScript types and readable property names for API documentation rather than JSDoc comments.
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: bratsos
PR: clerk/javascript#6259
File: packages/clerk-js/src/ui/components/SignUp/signUpFormHelpers.ts:377-379
Timestamp: 2025-07-07T16:57:10.869Z
Learning: In the Clerk JavaScript repository, when working with TypeScript decision tables or rule-based systems, redundant-looking ternary operators may be intentionally kept for TypeScript type narrowing when the compiler cannot infer that a value is non-null despite conditional checks. This is a pragmatic approach to handle TypeScript's type system limitations without overcomplicating the code.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use immutable update patterns (spread, etc.) for objects and arrays
Learnt from: jacekradko
PR: clerk/javascript#5905
File: .changeset/six-ears-wash.md:1-3
Timestamp: 2025-06-26T03:27:05.535Z
Learning: In the Clerk JavaScript repository, changeset headers support single quotes syntax (e.g., '@clerk/backend': minor) and work fine with their current changesets integration, so there's no need to change them to double quotes.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Proper use of utility types instead of manual type construction
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/@clerk/*/package.json : Framework packages must depend on '@clerk/clerk-js' for core functionality.
Learnt from: panteliselef
PR: clerk/javascript#6327
File: .changeset/eight-socks-lead.md:2-4
Timestamp: 2025-07-16T10:43:17.706Z
Learning: In the Clerk JavaScript repository, APIs marked with @experimental JSDoc annotations can have breaking changes released with minor version bumps rather than major version bumps, as consumers are warned about the instability of experimental features.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: panteliselef
PR: clerk/javascript#6285
File: packages/types/src/commerce.ts:1305-1305
Timestamp: 2025-07-11T18:08:14.697Z
Learning: In the Clerk JavaScript repository, when there's a conflict between naming consistency (camelCase) and avoiding breaking changes, the team prioritizes maintaining backward compatibility over enforcing naming conventions, even for experimental APIs.
packages/clerk-js/src/core/resources/CommercePlan.ts (4)
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: panteliselef
PR: clerk/javascript#6327
File: .changeset/eight-socks-lead.md:2-4
Timestamp: 2025-07-16T10:43:17.706Z
Learning: In the Clerk JavaScript repository, APIs marked with @experimental JSDoc annotations can have breaking changes released with minor version bumps rather than major version bumps, as consumers are warned about the instability of experimental features. The billing feature specifically has an @experimental annotation stating "This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change."
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/@clerk/*/package.json : Framework packages must depend on '@clerk/clerk-js' for core functionality.
packages/types/src/clerk.ts (7)
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper type definitions for props and state
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use type-only imports: `import type { ... }`
Learnt from: LauraBeatris
PR: clerk/javascript#6273
File: packages/testing/src/playwright/unstable/page-objects/sessionTask.ts:22-27
Timestamp: 2025-07-11T17:12:28.495Z
Learning: In Clerk's test utilities, particularly for page objects like sessionTask.ts, when handling task type enums, prefer graceful handling of unknown/unsupported task types rather than throwing errors. This prevents breaking existing tests when new task types are introduced to the SessionTask['key'] union type.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use `type` for unions, primitives, and computed types
Learnt from: bratsos
PR: clerk/javascript#6259
File: packages/clerk-js/src/ui/components/SignUp/signUpFormHelpers.ts:377-379
Timestamp: 2025-07-07T16:57:10.869Z
Learning: In the Clerk JavaScript repository, when working with TypeScript decision tables or rule-based systems, redundant-looking ternary operators may be intentionally kept for TypeScript type narrowing when the compiler cannot infer that a value is non-null despite conditional checks. This is a pragmatic approach to handle TypeScript's type system limitations without overcomplicating the code.
packages/types/src/json.ts (2)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use type-only imports: `import type { ... }`
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Applies to packages/**/*.{ts,tsx,d.ts} : Packages should export TypeScript types alongside runtime code
packages/types/src/commerce.ts (9)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use `type` for unions, primitives, and computed types
Learnt from: panteliselef
PR: clerk/javascript#6327
File: .changeset/eight-socks-lead.md:2-4
Timestamp: 2025-07-16T10:43:17.706Z
Learning: In the Clerk JavaScript repository, APIs marked with @experimental JSDoc annotations can have breaking changes released with minor version bumps rather than major version bumps, as consumers are warned about the instability of experimental features. The billing feature specifically has an @experimental annotation stating "This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change."
Learnt from: panteliselef
PR: clerk/javascript#6327
File: .changeset/eight-socks-lead.md:2-4
Timestamp: 2025-07-16T10:43:17.706Z
Learning: In the Clerk JavaScript repository, APIs marked with @experimental JSDoc annotations can have breaking changes released with minor version bumps rather than major version bumps, as consumers are warned about the instability of experimental features.
Learnt from: panteliselef
PR: clerk/javascript#6285
File: packages/types/src/commerce.ts:1305-1305
Timestamp: 2025-07-11T18:08:14.697Z
Learning: In the Clerk JavaScript repository, when there's a conflict between naming consistency (camelCase) and avoiding breaking changes, the team prioritizes maintaining backward compatibility over enforcing naming conventions, even for experimental APIs.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/@clerk/*/package.json : Framework packages must depend on '@clerk/clerk-js' for core functionality.
Learnt from: bratsos
PR: clerk/javascript#6259
File: packages/clerk-js/src/ui/components/SignUp/signUpFormHelpers.ts:377-379
Timestamp: 2025-07-07T16:57:10.869Z
Learning: In the Clerk JavaScript repository, when working with TypeScript decision tables or rule-based systems, redundant-looking ternary operators may be intentionally kept for TypeScript type narrowing when the compiler cannot infer that a value is non-null despite conditional checks. This is a pragmatic approach to handle TypeScript's type system limitations without overcomplicating the code.
Learnt from: dstaley
PR: clerk/javascript#6100
File: packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx:121-124
Timestamp: 2025-06-16T17:08:58.414Z
Learning: The @clerk/clerk-js package only supports browsers released in the last two years (since May 8, 2023), so modern CSS features like color-mix() are fully supported across all target browsers without requiring fallbacks.
Learnt from: wobsoriano
PR: clerk/javascript#6229
File: packages/backend/src/api/endpoints/MachineTokensApi.ts:47-89
Timestamp: 2025-07-01T15:20:41.834Z
Learning: In the Clerk JavaScript repository, for the MachineTokensApi class (packages/backend/src/api/endpoints/MachineTokensApi.ts), the maintainers prefer to rely on TypeScript types and readable property names for API documentation rather than JSDoc comments.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/*/package.json : All packages must be published under the @clerk namespace on npm.
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (11)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper type definitions for props and state
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use `type` for unions, primitives, and computed types
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Proper use of utility types instead of manual type construction
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper subscription cleanup
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use type-only imports: `import type { ... }`
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper event types for handlers
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use branded types for domain safety
Learnt from: wobsoriano
PR: clerk/javascript#6123
File: packages/nextjs/src/server/__tests__/getAuthDataFromRequest.test.ts:63-75
Timestamp: 2025-06-16T01:27:54.563Z
Learning: In packages/nextjs/src/server/data/getAuthDataFromRequest.ts, the tokenType behavior on mismatch is intentionally different between array and single acceptsToken values: when acceptsToken is an array and the token type doesn't match any in the array, tokenType returns null; when acceptsToken is a single value and the token type doesn't match, tokenType returns the requested single value. This design aligns with developer intent and provides a more ergonomic API for common use cases.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use Context API for theme/authentication
🧬 Code Graph Analysis (5)
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx (1)
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (1)
  • SubscriberTypeContext (5-5)
packages/clerk-js/src/core/resources/CommercePlan.ts (1)
packages/types/src/commerce.ts (1)
  • CommercePayerType (88-88)
packages/types/src/clerk.ts (1)
packages/types/src/commerce.ts (1)
  • CommercePayerType (88-88)
packages/types/src/json.ts (1)
packages/types/src/commerce.ts (1)
  • CommercePayerType (88-88)
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (1)
packages/types/src/commerce.ts (1)
  • CommercePayerType (88-88)
⏰ 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: semgrep-cloud-platform/scan
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (14)
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx (1)

61-61: LGTM! Property access correctly updated for the new type structure.

The change from plan.payerType[0] to plan.forPayerType properly aligns with the refactoring from array-based to single-value payer type, improving type safety and eliminating potential array access errors.

.changeset/proud-pianos-attack.md (1)

1-7: LGTM! Changeset properly documents the billing type refactoring.

The changeset correctly identifies both affected packages, uses appropriate minor version bumps for experimental API changes, and provides a clear description of the change from array-based to single-value payer type.

packages/clerk-js/src/core/resources/CommercePlan.ts (4)

1-1: LGTM! Import correctly updated for the new type.

The addition of CommercePayerType to the imports properly supports the property type change from array to single value.


20-20: LGTM! Property type correctly updated to use strict union type.

The change from payerType!: string[] to forPayerType!: CommercePayerType improves type safety by using the strict 'org' | 'user' union instead of a generic string array, and the property rename aligns with the broader refactoring.


50-50: LGTM! JSON deserialization updated for new API structure.

The assignment now correctly uses data.for_payer_type instead of data.payer_type, matching the updated JSON interface structure.


76-76: LGTM! Snapshot serialization maintains consistency.

The serialization key is correctly updated to for_payer_type to match the new JSON structure and property naming.

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

13-13: LGTM! Import correctly added for the new union type.

The addition of CommercePayerType to the imports properly supports the interface property type change.


647-647: LGTM! JSON interface property correctly updated.

The change from payer_type: string[] to for_payer_type: CommercePayerType properly reflects the API structure change from array-based to single-value payer type with strict typing, using appropriate snake_case naming for JSON interfaces.

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

26-30: Type-only import looks good.

Using import type { CommercePayerType } … follows the repo’s guideline for type-only imports, preventing it from ending up in the JS bundle.


1840-1847: 👍 Prop type update is consistent with new alias.

for?: CommercePayerType; correctly adopts the new union type and keeps the public API unchanged otherwise.

packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (1)

1-1: Good use of type-only import.

The context module now imports CommercePayerType with import type, matching the repo rules.

packages/types/src/commerce.ts (3)

88-88: Good type alias definition following TypeScript best practices.

The type alias correctly uses the type keyword for a union type, which aligns with the coding guidelines that specify using type for unions, primitives, and computed types.


217-217: Improved type safety with strict union type.

The change from the previous array-based type to the strict CommercePayerType union ('org' | 'user') provides better type safety and prevents invalid values from being passed to the for parameter.


360-360: Property name and type changes enhance consistency.

The refactoring from payerType: string[] to forPayerType: CommercePayerType provides several improvements:

  1. Better naming consistency - The property name forPayerType is more descriptive than payerType
  2. Type safety - Using the specific CommercePayerType union instead of string[] prevents invalid values
  3. Simplified data model - A single value instead of an array simplifies the API

The documentation comment appropriately explains the purpose of this property.

Copy link

pkg-pr-new bot commented Jul 17, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: 78e1cfd

@panteliselef panteliselef merged commit 10e1060 into main Jul 18, 2025
38 checks passed
@panteliselef panteliselef deleted the elef/com-1058-drop-payer_type-array-for-for_payer_type-string branch July 18, 2025 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants