Skip to content

Fix Stripe.ErrorType.StripeError incorrectly being usable as a runtime class#2758

Merged
xavdid merged 1 commit into
masterfrom
DEVSDK-3141
Jun 18, 2026
Merged

Fix Stripe.ErrorType.StripeError incorrectly being usable as a runtime class#2758
xavdid merged 1 commit into
masterfrom
DEVSDK-3141

Conversation

@xavdid

@xavdid xavdid commented Jun 18, 2026

Copy link
Copy Markdown
Member

Why?

Because of the way our errors were re-exported, Typescript allowed the use of Stripe.ErrorType in runtime code:

// passed `tsc`, but shouldn't:
if (error instanceof Stripe.ErrorType.StripeError) { 
  // ...
}

But at runtime, it would blow up:

16 |   if (error instanceof Stripe.ErrorType.StripeError) {
                                   ^
TypeError: undefined is not an object (evaluating 'Stripe.ErrorType.StripeError')

This was caused by the way we exported ErrorType. It was being described as a class by the type system, but was only usable as a type. To fix, we don't export it as a class in the type system anymore. There's no runtime impact of this, it's purely a types change

Note: I believe we don't need ErrorType any more at all. It was added to work around this bug, but given that .errors now works the way we expect (both as a type and as a value) we can probably drop it in the next major (filed as DEVSDK-3165)

What?

  • explicitly export a namespace of errors instead of the runtime module _Error

See Also

@xavdid xavdid requested a review from a team as a code owner June 18, 2026 19:08
@xavdid xavdid requested review from jar-stripe and removed request for a team June 18, 2026 19:08

@jar-stripe jar-stripe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Change looks good. Small bit: the PR description could probably be edited a bit, but otherwise GTG

@xavdid xavdid merged commit 047dd0c into master Jun 18, 2026
11 checks passed
@xavdid xavdid deleted the DEVSDK-3141 branch June 18, 2026 20:06
xavdid added a commit that referenced this pull request Jun 18, 2026
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.

2 participants