Skip to content

Fix export for Stripe.Decimal in CJS and ESM#2626

Merged
prathmesh-stripe merged 1 commit intomasterfrom
prathmesh/fix-decimal-in-esm
Mar 26, 2026
Merged

Fix export for Stripe.Decimal in CJS and ESM#2626
prathmesh-stripe merged 1 commit intomasterfrom
prathmesh/fix-decimal-in-esm

Conversation

@prathmesh-stripe
Copy link
Contributor

@prathmesh-stripe prathmesh-stripe commented Mar 26, 2026

Why?

User reported an issue where they were unable to access Stripe.Decimal in the Node SDK while using TypeScript and ESM import.

Decimal class wasn't exported correctly and this is a problem with both CJS and ESM style of imports.

What?

  • Added a Decimal property on the exported Stripe class.
  • Added integration tests

See Also

#2625

Changelog

  • Fixes runtime error when using Stripe.Decimal. Resolves #2625

@prathmesh-stripe prathmesh-stripe requested a review from a team as a code owner March 26, 2026 08:56
@prathmesh-stripe prathmesh-stripe requested review from jar-stripe and removed request for a team March 26, 2026 08:56
@prathmesh-stripe prathmesh-stripe enabled auto-merge (squash) March 26, 2026 09:01
@prathmesh-stripe prathmesh-stripe force-pushed the prathmesh/fix-decimal-in-esm branch from 8e6fae0 to 38ebe1a Compare March 26, 2026 15:03
@prathmesh-stripe prathmesh-stripe force-pushed the prathmesh/fix-decimal-in-esm branch from 38ebe1a to 329a188 Compare March 26, 2026 15:16
Copy link
Contributor

@mbroshi-stripe mbroshi-stripe left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for adding the integration test!

@prathmesh-stripe prathmesh-stripe merged commit f689326 into master Mar 26, 2026
10 checks passed
@prathmesh-stripe prathmesh-stripe deleted the prathmesh/fix-decimal-in-esm branch March 26, 2026 15:52
@prathmesh-stripe prathmesh-stripe changed the title Export Decimal correctly in ESM Fix issue with undefined Stripe.Decimal in CJS and ESM Mar 26, 2026
@prathmesh-stripe prathmesh-stripe changed the title Fix issue with undefined Stripe.Decimal in CJS and ESM Fix export of Stripe.Decimal in CJS and ESM Mar 26, 2026
@prathmesh-stripe prathmesh-stripe changed the title Fix export of Stripe.Decimal in CJS and ESM Fix export for Stripe.Decimal in CJS and ESM Mar 26, 2026
jar-stripe added a commit that referenced this pull request Mar 27, 2026
The Decimal class was accessible as a runtime value via Stripe.Decimal
(after #2626), but could not be used as a TypeScript type annotation.
Writing `const d: Stripe.Decimal = Stripe.Decimal.from('1.0')` produced
TS2749: "'Stripe.Decimal' refers to a value, but is being used as a
type here."

This adds Decimal to the Stripe namespace as a type in three places:
- stripe.core.ts (shared namespace definition)
- stripe.esm.node.ts (namespace + named module export)
- stripe.cjs.node.ts (namespace on the CJS export wrapper)

After this change, all of these work:
- ESM: `const d: Stripe.Decimal = Stripe.Decimal.from('1.0')`
- ESM: `import { Decimal } from 'stripe'` (named import)
- CJS: `const d: Stripe.Decimal = Stripe.Decimal.from('1.0')`

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stripe.Decimal is undefined at runtime even though TypeScript doesn't complain

3 participants