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

Replace JSX with React.JSX #595

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

memark
Copy link
Contributor

@memark memark commented Oct 6, 2024

The global JSX type is deprecated in React 18.3 and removed in React 19 RC. This PR changes the code to use the supported React.JSX syntax instead.

Copy link

vercel bot commented Oct 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
goober-rocks ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 6, 2024 5:06pm

Copy link

codesandbox-ci bot commented Oct 6, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@cristianbote
Copy link
Owner

Heya @memark thanks for opening this PR. Changes look good, wondering though if this should be a major or minor update? 🤔 If it's minor then types will break for usual versioning?

@memark
Copy link
Contributor Author

memark commented Oct 7, 2024

This is the info I could find (which is a bit vague)
https://react.dev/blog/2024/04/25/react-19-upgrade-guide#the-jsx-namespace-in-typescript

Digging through the TS defs I find this

old

declare global {
    /**
     * @deprecated Use `React.JSX` instead of the global `JSX` namespace.
     */
    namespace JSX {
        interface IntrinsicElements {
            ...
        }
    }
}

new

declare namespace React {
    namespace JSX {
        interface IntrinsicElements extends GlobalJSXIntrinsicElements {}
    }
}

interface GlobalJSXIntrinsicElements extends JSX.IntrinsicElements {}

meaning that both references end up in the same place. So not a breaking change I would say.

@cristianbote
Copy link
Owner

Thanks for looking into it @memark. Looks good, I'll merge and push a new version.

@cristianbote cristianbote merged commit 393ecd5 into cristianbote:master Oct 7, 2024
8 checks passed
@cristianbote
Copy link
Owner

Published 2.1.15
https://github.com/cristianbote/goober/releases/tag/v2.1.15

@JamiesWhiteShirt
Copy link

This change broke the documented workaround for getting types to work with Goober + Preact + Typescript. https://goober.js.org/features/typescript#note-when-using-preact

// preact.d.ts

import JSX = preact.JSX;

This variant seems to do the trick:

// preact.d.ts

namespace React {
  export import JSX = preact.JSX;
}

@memark
Copy link
Contributor Author

memark commented Nov 14, 2024

Nice find! Seems like a reasonable fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants