Skip to content

Switch from JSX.Element to React.JSX.Element#5986

Merged
dylans merged 1 commit intoianstormtaylor:mainfrom
ebroder:react-v19
Dec 31, 2025
Merged

Switch from JSX.Element to React.JSX.Element#5986
dylans merged 1 commit intoianstormtaylor:mainfrom
ebroder:react-v19

Conversation

@ebroder
Copy link
Contributor

@ebroder ebroder commented Dec 9, 2025

Description

The global JSX namespace has been deprecated for around two and a half years now in favor of using React.JSX, and as of the type declarations for React 19, it's been fully removed. By switching to the new namespace, this package maintains compatibility with React 19.

Without this change, attempting to use React 19 with slate-react and TypeScript results in typechecking errors:

node_modules/slate-react/dist/components/text.d.ts:8:59 - error TS2503: Cannot find namespace 'JSX'.

8     renderPlaceholder: (props: RenderPlaceholderProps) => JSX.Element;
                                                            ~~~

node_modules/slate-react/dist/components/text.d.ts:9:47 - error TS2503: Cannot find namespace 'JSX'.

9     renderLeaf?: ((props: RenderLeafProps) => JSX.Element) | undefined;
                                                ~~~

node_modules/slate-react/dist/components/text.d.ts:10:47 - error TS2503: Cannot find namespace 'JSX'.

10     renderText?: ((props: RenderTextProps) => JSX.Element) | undefined;
                                                 ~~~

Issue

N/A

Example

Context

The React.JSX namespace was introduced and global JSX was deprecated both in DefinitelyTyped/DefinitelyTyped#64464, which was published as v18.2.6 of @types/react (n.b.: version numbers in @types/ packages are only loosely connected to upstream version numbers).

Since TypeScript is structurally-typed, the types React.JSX.Element and JSX.Element should be functionally equivalent to the typechecker, so as long as users have a version of @types/react that includes both declarations, this should not cause a backwards compatibility issue.

Ideally, we would enforce that users had v18.2.6 or later of @types/react, but given the nature of type dependencies, that's not possible. (There's no way to have a non-dev dependency introduce new dev dependencies). But presumably anyone who is proactively updating this package is also updating their type declarations as well.

Checks

  • The new code matches the existing patterns and styles.
  • The tests pass with yarn test.
  • The linter passes with yarn lint. (Fix errors with yarn fix.)
  • The relevant examples still work. (Run examples with yarn start.)
  • You've added a changeset if changing functionality. (Add one with yarn changeset add.)

@changeset-bot
Copy link

changeset-bot bot commented Dec 9, 2025

🦋 Changeset detected

Latest commit: 54b4063

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
slate-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

The global JSX namespace has been deprecated for around two and a half
years now in favor of using React.JSX, and as of the type declarations
for React 19, it's been fully removed. By switching to the new
namespace, this package maintains compatibility with React 19.
Copy link
Collaborator

@dylans dylans left a comment

Choose a reason for hiding this comment

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

I'm ok with this for now, but I'd actually like to see us move away from using import React from 'react' and more directly import what we use, but that's a much bigger change.

@ebroder
Copy link
Contributor Author

ebroder commented Dec 26, 2025

Is there anything I can do on my end to encourage merging and releasing this? AFAIK it's the last blocker for us to upgrade.

@dylans dylans merged commit 6628383 into ianstormtaylor:main Dec 31, 2025
15 of 16 checks passed
This was referenced Dec 31, 2025
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