Uh oh!
There was an error while loading. Please reload this page.
Conversation
There was a problem hiding this comment.
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
ChristianMurphy
left a comment
There was a problem hiding this comment.
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.
Is this related to syntax-tree/hast-util-to-jsx-runtime#6 ?
There was a problem hiding this comment.
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.
Would be nice to solve such things instead of ts-expect-error
There was a problem hiding this comment.
I agree, but that issue has been proven hard to resolve upstream. (If it can be resolved upstream at all.) This @ts-expect-error is internal anyway, and this change unblocks a lot of users.
bluepeter
commented
Dec 26, 2024
Let's make this happen! |
wooorm
commented
Jan 1, 2025
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.
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.
ElementType includes JSX.IntrinsicElements.
There was a problem hiding this comment.
@remcohaszing No, I mean keyof? Does this allow b: 'i'. I assume not, because i or all other element names are not related to props?
There was a problem hiding this comment.
It does! And there’s also a pre-existing test which covers this.
There was a problem hiding this comment.
right no that, I meant in the @types/react code
There was a problem hiding this comment.
It feels like it could be a bug that @types/react supports this today — that they could remove it somewhere in the future
There was a problem hiding this comment.
not sure where it happens but when I change that line to h1: 'x-y' we get a type error — which indicates that I should worry less because it is type checked — even though the types should likely allow custom elements like that.
Uh oh!
There was an error while loading. Please reload this page.
| // @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.
Would be nice to solve such things instead of ts-expect-error
ChristianMurphy
commented
Jan 1, 2025
What a very somber and philosophical question 😆 If you are asking why it appeared on this PR as a reviewer. |
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.
wooorm
commented
Jan 2, 2025
And, are you happy with it? 😅 I am emboldened in my view that I am not happy with it 😅 |
remcohaszing
commented
Jan 2, 2025
I’m fine with @ChristianMurphy wanting to try Copilot reviews, but IMO the result is really pointless, at least in this case. |
wooorm
commented
Jan 2, 2025
Of course! Always up for trying things out! |
This comment has been minimized.
This comment has been minimized.
ChristianMurphy
commented
Jan 2, 2025
It's not perfect, but getting better.
Okay
It was in this case. |
cyberluke
commented
Jan 6, 2025
Why not reuse this solution: quantizor/markdown-to-jsx@918b44b#diff-4b76aeed93d86ab1e483e12333e1bae64ccdc1a1e4fd27bec2b32f41db08e6cfR5 and just change: to in complex-types.ts and complex-types.d.ts? |
remcohaszing
commented
Jan 6, 2025
The goal of |
wooorm
commented
Jan 6, 2025
Released in |
wooorm
commented
Jan 6, 2025
done in |
Hello @wooorm, I don't see the d.ts files, only the version change in the changelog 9.0.2...9.0.3 |
ChristianMurphy
commented
Jan 11, 2025
@ludobonnet .d.ts are aren't checked into source, so they won't show in the diff, they are artifacts on npm. |
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