Skip to content
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

React 19 types compatibility #2487

Open
4 tasks done
snowystinger opened this issue May 30, 2024 · 5 comments
Open
4 tasks done

React 19 types compatibility #2487

snowystinger opened this issue May 30, 2024 · 5 comments
Labels
🌊 blocked/upstream This cannot progress before something external happens first

Comments

@snowystinger
Copy link

snowystinger commented May 30, 2024

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 DefinitelyTyped/DefinitelyTyped#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
Copy link
Member

@ChristianMurphy ChristianMurphy added the 🌊 blocked/upstream This cannot progress before something external happens first label May 30, 2024
@snowystinger
Copy link
Author

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

@wooorm wooorm changed the title React 19 incompatibility React 19 types compatibility May 30, 2024
@karlhorky
Copy link
Contributor

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
Copy link

eps1lon commented Jun 25, 2024

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)

@wooorm
Copy link
Member

wooorm commented Oct 11, 2024

Inlining what I believe Sebastian links to:

Users can support the unreleased version of React 19’s types by defining the JSX namespace that they remove:

import type {JSX as Jsx} from 'react/jsx-runtime'

declare global {
  namespace JSX {
    type ElementClass = Jsx.ElementClass
    type Element = Jsx.Element
    type IntrinsicElements = Jsx.IntrinsicElements
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌊 blocked/upstream This cannot progress before something external happens first
Development

No branches or pull requests

5 participants