fix: CJS companion namespace access for resource types at all depths#2765
Merged
Conversation
Regenerated from stripe/sdk-codegen#3768 which fixes: - Resource sub-types (e.g. Stripe.Price.Recurring) now accessible in CJS - Nested resource types (e.g. Stripe.Billing.Alert.Status) now accessible in both CJS and ESM - Deep params namespaces (e.g. AccountCreateParams.BusinessProfile.AnnualRevenue) now accessible in CJS Fixes #2683 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
Adds type assertions for patterns that were previously broken in CJS (and some in ESM too): - Resource sub-types: Stripe.Price.Recurring, Stripe.Customer.InvoiceSettings - Deep resource sub-types: Stripe.Subscription.BillingMode.Type - Nested resource sub-types: Stripe.Billing.Alert.Status, Stripe.Terminal.Configuration.Tipping, Stripe.Apps.Secret.Scope - Deep params: Stripe.AccountCreateParams.BusinessProfile.AnnualRevenue Added to both testProjects/types/ (ESM) and testProjects/types-cjs-node16/ (CJS) so both declaration files are covered. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
xavdid
approved these changes
Jun 24, 2026
xavdid
left a comment
Member
There was a problem hiding this comment.
Looks good! had a comment about more test coverage, but looks good otherwise
Same coverage as types/ and types-cjs-node16/ — covers module: commonjs / moduleResolution: node resolution mode. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why?
CJS consumers can't access nested type namespaces like
Stripe.Price.Recurring,Stripe.Billing.Alert.Status, orStripe.Terminal.Configuration.Tipping. The CJS declaration file uses flat type aliases insidedeclare namespace StripeConstructor, which drops companion namespaces that ESM carries automatically viaexport { X }.Additionally, nested resource types (under product namespaces like Billing, Terminal, Apps, etc.) were broken in both ESM and CJS because companion namespace blocks were rendered nested under the product namespace instead of at module scope where they merge with the interface.
After this change, all type paths that work in ESM also work in CJS.
What?
export namespace Alert { ... }) instead of nested under the product namespace (export namespace Billing { export namespace Alert { ... } })Price.Recurring,Alert.Status) at all depthsBilling.Alert.Status→Alert.Status)See Also
import type Stripe from 'stripe'does not exposeStripe.Customer#2683Changelog
Stripe.Price.Recurring,Stripe.Subscription.BillingMode)Stripe.Billing.Alert.Status,Stripe.Terminal.Configuration.Tippingin both ESM and CJS modes.