Export Decimal type from Stripe namespace#2703
Merged
mbroshi-stripe merged 2 commits intomasterfrom May 6, 2026
Merged
Conversation
Users could not use `Stripe.Decimal` as a type annotation because the namespace only exposed the companion object (value), not the branded type. This adds an explicit type export using an inline import to avoid the circular definition that a direct re-export would cause. Fixes #2698 Co-Authored-By: Claude Opus 4.6 <[email protected]> Committed-By-Agent: claude
There was a problem hiding this comment.
Pull request overview
This PR makes Stripe.Decimal usable in TypeScript type positions by exporting the branded Decimal type from the Stripe namespace (so Stripe.Decimal works as both a value and a type), and adds a type-test to validate the behavior.
Changes:
- Exported
Decimalas a type withindeclare namespace Stripein the ESM typings (stripe.core.tsandstripe.esm.node.ts) using an inlineimport()type reference. - Updated the TypeScript test project to assert
Stripe.Decimalworks in a parameter type annotation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| testProjects/types/typescriptTest.ts | Adds a compile-time check that Stripe.Decimal can be used as a type annotation. |
| src/stripe.esm.node.ts | Exposes Stripe.Decimal as a type within the Stripe namespace for ESM typings. |
| src/stripe.core.ts | Exposes Stripe.Decimal as a type within the core Stripe namespace typings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
xavdid
approved these changes
May 6, 2026
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?
Users cannot use
Stripe.Decimalas a type annotation (e.g.function takesDecimal(d: Stripe.Decimal)) because TypeScript only sees the companion object value, not the branded type. This forces ugly workarounds liketypeof Stripe.Decimal.zero.What?
export type Decimal = import('./shared.js').Decimalto thedeclare namespace Stripeblock in bothstripe.core.tsandstripe.esm.node.tsstatic Decimalproperty)Stripe.Decimalworks as a type annotationSee Also
Changelog
Stripe.Decimalas a usable type in theStripenamespace, enabling type annotations likefunction takesDecimal(d: Stripe.Decimal).