-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Typescript Error ts(2322) for Nested MDX Components in React19 environment #2579
Comments
|
Thanks @wooorm; I added the global JSX namespace in the Next.js 15 project the location where I need to use nested MDX components. In this time, the import type { JSX as ReactJSX } from "react";
declare global {
namespace JSX {
type IntrinsicElements = ReactJSX.IntrinsicElements;
}
} As author of Thanks for the answer. |
👍 yep I do — for now I think it best that end users choose! |
Thank you very much @wooorm. |
Initial checklist
Affected package
mdx/types@latest
Steps to reproduce
Related with the type
MDXComponents
of@types/mdx
, I am facing a typescript error ts2322 in react19 environment (no problem with react18):The type
MDXComponents
raises an error for nested MDX components, under themotion
key specifically in above example , saying:I suppose the typescript can not narrow
NestedMDXComponents
toFunctionComponent<Props>
orClassComponent<Props>
. I don't know the issue may be related with JSX issue, because when I add the code suggested by @wooorm disappears the error, but couldn't figure out the reason.I also saw a typescript comment in the documentation (using-mdx.mdx) here
I created two minimal apps with Next.js to investigate the error:
MDXComponents
for nested MDX components.Actual behavior
The typescript throws aforementioned error for the type
MDXComponents
for nested MDX components in React19 environment.Expected behavior
Normally, it would work with nested MDX components without any typescript error.
Runtime
node@20
Package manager
npm@11
Operating system
macOS@latest
Build and bundle tools
Next.js
The text was updated successfully, but these errors were encountered: