fix(react-19): switch JSX.Element to React.ReactElement to support React 19 and 18 #437
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.
As of React 19, the
JSX
namespace is no longer global. It now usesReact.JSX
.https://react.dev/blog/2024/04/25/react-19-upgrade-guide#the-jsx-namespace-in-typescript
As a result, usages of
JSX.Element
in this library throw type errors:In
@types/react
,React.ReactElement
appears to be equivalent toJSX.Element
in v18 and andReact.JSX.Element
in v19. Using that type in place ofJSX.Element
should work in both React versions.v18: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/v18/index.d.ts#L4363
v19: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L4077
Unfortunately I get errors when running
yarn build
so this should be checked before merging. Perhaps I should be using an older version of Yarn. I have the latest version and it seems to modify the lock file dramatically.Solves #434
@lukasbach