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 Support #3186

Open
karlhorky opened this issue May 15, 2024 · 2 comments
Open

React 19 Types Support #3186

karlhorky opened this issue May 15, 2024 · 2 comments

Comments

@karlhorky
Copy link

karlhorky commented May 15, 2024

The problem

Using React 19 with the version of TypeScript types mentioned in the upgrade guide (using pnpm overrides to avoid mismatching types) causes failures with the Emotion types:

@jsxImportSource of @emotion/react

/** @jsxImportSource @emotion/react */

export default function ChevronList() {
  return (
    // 💥 Property 'ul' does not exist on type 'JSX.IntrinsicElements'. ts(2339)
    <ul />
  );
}

@emotion/styled

import styled from '@emotion/styled';

const ArrowListItem =
  // 💥 Property 'li' does not exist on type 'CreateStyled'. ts(2339)
  styled.li``

Relevant parts of my package.json:

{
  "dependencies": {
    "@emotion/react": "11.11.4",
    "@emotion/styled": "11.11.5",
    "next": "14.3.0-canary.63",
    "react": "19.0.0-beta-4508873393-20240430",
    "react-dom": "19.0.0-beta-4508873393-20240430"
  },
  "devDependencies": {
    "@types/react": "npm:types-react@19.0.0-beta.1",
    "@types/react-dom": "npm:types-react-dom@19.0.0-beta.1"
  },
  "packageManager": "pnpm@9.1.1",
  "pnpm": {
    "overrides": {
      "@types/react": "npm:types-react@beta",
      "@types/react-dom": "npm:types-react-dom@beta"
    }
  }
}

Proposed solution

@emotion/react and @emotion/styled should be updated to support React 19

Alternative solutions

No viable alternatives I can think of, apart from not supporting React 19+

Additional context

--

@karlhorky
Copy link
Author

karlhorky commented May 15, 2024

Workaround

Use pnpm patch (or patch-package) to patch @emotion/react and @emotion/styled using the React 19 codemod:

pnpm patch --edit-dir ./node_modules/.pnpm-patch-emotion-react @emotion/react
cd ./node_modules/.pnpm-patch-emotion-react
npx types-react-codemod@latest preset-19 .
cd ../..
pnpm patch-commit ./node_modules/.pnpm-patch-emotion-react
rm -r ./node_modules/.pnpm-patch-emotion-react

pnpm patch --edit-dir ./node_modules/.pnpm-patch-emotion-styled @emotion/styled
cd ./node_modules/.pnpm-patch-emotion-styled
npx types-react-codemod@latest preset-19 .
cd ../..
pnpm patch-commit ./node_modules/.pnpm-patch-emotion-styled
rm -r ./node_modules/.pnpm-patch-emotion-styled

@Andarist
Copy link
Member

We'll get to work on this once React 19 gets published.

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

No branches or pull requests

2 participants