Skip to content

[BUG]: React 19 global JSX namespace deprecation #569

@bagedevimo

Description

@bagedevimo

What happened?

As part of the React 19 release they've deprecated the JSX global namespace, in favour of React.JSX.Element. While y'all aren't explicitly using JSX.Element anywhere, it does it appear in the emitted type definition files, specifically:

node_modules/@stripe/react-stripe-js/dist/react-stripe.d.ts:715:79 - error TS2503: Cannot find namespace 'JSX'.

715 declare const EmbeddedCheckout: ({ id, className }: EmbeddedCheckoutProps) => JSX.Element;

The "easy" fix for this is to use React 19 in the package.json which shouldn't really cause any changes in your library. I had a little try at this locally and discovered the following diffs - ignoring the crappy one-liner to find all the diffs.

❯ ls -1 dist-before/* | cut -d '/' -f 2 | xargs -I{} bash -c "echo {} && diff dist-before/{} dist/{}"
react-stripe.d.ts
1a2
> import React from "react";
715c716
< declare const EmbeddedCheckout: ({ id, className }: EmbeddedCheckoutProps) => JSX.Element;
---
> declare const EmbeddedCheckout: ({ id, className }: EmbeddedCheckoutProps) => React.JSX.Element;
react-stripe.esm.d.mts
1a2
> import React from "react";
715c716
< declare const EmbeddedCheckout: ({ id, className }: EmbeddedCheckoutProps) => JSX.Element;
---
> declare const EmbeddedCheckout: ({ id, className }: EmbeddedCheckoutProps) => React.JSX.Element;
react-stripe.esm.mjs
react-stripe.js
react-stripe.umd.d.ts
1a2
> import React from "react";
715c716
< declare const EmbeddedCheckout: ({ id, className }: EmbeddedCheckoutProps) => JSX.Element;
---
> declare const EmbeddedCheckout: ({ id, className }: EmbeddedCheckoutProps) => React.JSX.Element;
react-stripe.umd.js
react-stripe.umd.min.d.ts
1a2
> import React from "react";
715c716
< declare const EmbeddedCheckout: ({ id, className }: EmbeddedCheckoutProps) => JSX.Element;
---
> declare const EmbeddedCheckout: ({ id, className }: EmbeddedCheckoutProps) => React.JSX.Element;
react-stripe.umd.min.js

However, yarn build now fails due to the script/check-imports script. I'm not 100% sure what the plan with that is, so didn't want to make an pull request without understanding the goal of this script.

Environment

No response

Reproduction

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions