-
-
Notifications
You must be signed in to change notification settings - Fork 884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for React 19 #879
base: main
Are you sure you want to change the base?
Conversation
Having them in the same block, can be problematic sometimes. For example when they contain `@template` tags.
This adds support for React 19 types, by removing the dependency on the types provided by hast-util-to-jsx-runtime, thus removing the dependency on the JSX global namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
index.js:4
- [nitpick] The re-addition of the ExtraProps typedef seems redundant and could be confusing. Consider removing it if not necessary.
* @typedef {import('./lib/index.js').ExtraProps} ExtraProps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @remcohaszing
// @ts-expect-error | ||
// React components are allowed to return numbers, | ||
// but not according to the types in hast-util-to-jsx-runtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this related to syntax-tree/hast-util-to-jsx-runtime#6 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhat yes. But also apparently hast-util-to-jsx-runtime
doesn’t support JSX.ElementType
, which JSX runtimes may optionally define. That adds another complexity on top of that issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to solve such things instead of ts-expect-error
Let's make this happen! |
Why does |
/** | ||
* @typedef {{ | ||
* [Key in Extract<ElementType, string>]?: ElementType<ComponentProps<Key> & ExtraProps> | ||
* }} Components | ||
* Map tag names to components. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this type is not equivalent to the previous Components
.
But this is listed as a patch.
Is it intentional that you remove keyof JSX.IntrinsicElements
?
* | ||
*/ | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with these changes, but it would be good to have different commits for things of varying importance. This commit/PR is very important, many humans will look at the change, and see this mix of important/trivial.
Not blocking, but like: feel free to commit such refactors things directly to main (Refactor code-style
), and use a PR for things that need eyes on them!
// @ts-expect-error | ||
// React components are allowed to return numbers, | ||
// but not according to the types in hast-util-to-jsx-runtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to solve such things instead of ts-expect-error
Initial checklist
Description of changes
This adds support for React 19 types, by removing the dependency on the types provided by hast-util-to-jsx-runtime, thus removing the dependency on the JSX global namespace.
Unfortunately the current setup doesn’t really allow testing the types against multiple React versions. #838 would enable that.
Closes #877