mdx-js / mdx

Markdown for the component era
https://mdxjs.com
MIT License
17.49k stars 1.14k forks source link

React 19 types compatibility #2487

Open snowystinger opened 4 months ago

snowystinger commented 4 months ago

Initial checklist

Problem

React has removed the JSX global namespace in React 19, as a result, it needs to be accessed via the React global namespace now React.JSX.

node_modules/@mdx-js/react/lib/index.d.ts:29:85 - error TS2503: Cannot find namespace 'JSX'.

29 export function MDXProvider({ components, children, disableParentContext }: Props): JSX.Element;

Solution

Update references to JSX

Follow https://github.com/DefinitelyTyped/DefinitelyTyped/pull/69022 for how to install the pre-release of the types and if you can, use the codemod

Alternatives

I don't think there's an alternative here

ChristianMurphy commented 4 months ago

See the discussion at https://github.com/DefinitelyTyped/DefinitelyTyped/pull/69142 In particular https://github.com/DefinitelyTyped/DefinitelyTyped/pull/69142#issuecomment-2037677573 and https://github.com/DefinitelyTyped/DefinitelyTyped/pull/69142#issuecomment-2049931211

snowystinger commented 4 months ago

Ah, thanks for the links, I find it hard to keep track of what's happening in definitely typed vs in the actual home of the project

karlhorky commented 3 months ago

Seems like there's another discussion thread over here:

I asked about it in that thread, but maybe the plans for the global JSX namespace in React 19 types indicate that MDX and related packages should be importing JSX somehow instead of using it as a global namespace.

eps1lon commented 3 months ago

You need to do the same you're already doing for Preact and other libraries using JSX. Considering how you test types with other libraries, I'd assume you want something like DefinitelyTyped/DefinitelyTyped@ca06234 (#69142)