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

TypeScript type error with React 19 types #1823

Closed
danielrentz opened this issue Dec 12, 2024 · 5 comments
Closed

TypeScript type error with React 19 types #1823

danielrentz opened this issue Dec 12, 2024 · 5 comments

Comments

@danielrentz
Copy link

🐛 Bug Report

Type error with React v19 types. The global type namespace JSX has been removed for better compatibility with other JSX libs.

https://react.dev/blog/2024/04/25/react-19-upgrade-guide#the-jsx-namespace-in-typescript

To Reproduce

just use @types/react v19 and react-i18next in a project, and run tsc (without skipLibChecks).

node_modules/react-i18next/index.d.ts:147:23 - error TS2694: Namespace 'global.JSX' has no exported member 'LibraryManagedAttributes'.

147   ResolvedProps = JSX.LibraryManagedAttributes<
                          ~~~~~~~~~~~~~~~~~~~~~~~~

Expected behavior

no type error

Your Environment

  • runtime version: i.e. node v20.18.0
  • i18next version: i.e. 24.1.0
  • os: Windows 11
  • React version: 19.0.0
  • @types/react version: 19.0.1
@adrai
Copy link
Member

adrai commented Dec 12, 2024

Can you check if this addressed that issue? #1822

@danielrentz
Copy link
Author

@adrai Exactly!

@adrai
Copy link
Member

adrai commented Dec 12, 2024

addressed in v15.2.0

@adrai adrai closed this as completed Dec 12, 2024
@danielrentz
Copy link
Author

@adrai works for me, thank you!

alexandresoro pushed a commit to alexandresoro/ouca-backend that referenced this issue Dec 22, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [react-i18next](https://github.com/i18next/react-i18next) | dependencies | minor | [`15.1.4` -> `15.2.0`](https://renovatebot.com/diffs/npm/react-i18next/15.1.4/15.2.0) |

---

### Release Notes

<details>
<summary>i18next/react-i18next (react-i18next)</summary>

### [`v15.2.0`](https://github.com/i18next/react-i18next/blob/HEAD/CHANGELOG.md#1520)

[Compare Source](i18next/react-i18next@v15.1.4...v15.2.0)

This version may be breaking if you still use React < v18 with TypeScript.
For JS users this version is equal to v15.1.4

-   fix: Global JSX namespace is deprecated [1823](i18next/react-i18next#1823) with [1822](i18next/react-i18next#1822)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS44MC4wIiwidXBkYXRlZEluVmVyIjoiMzkuODAuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIl19-->

Reviewed-on: https://git.tristess.app/alexandresoro/ouca/pulls/404
Reviewed-by: Alexandre Soro <[email protected]>
Co-authored-by: renovate <[email protected]>
Co-committed-by: renovate <[email protected]>
@saitejayelubolu
Copy link

Typescript React follows these steps:

npm install -g typescript

then

npm uninstall react react-dom

then

npm install react@18 react-dom@18

then

npm install --no-audit --save @testing-library/jest-dom@^5.14.1 @testing-library/react@^13.0.0 @testing-library/user-event@^13.2.1 @types/jest@^27.0.1 @types/node@^16.7.13 @types/react@^18.0.0 @types/react-dom@^18.0.0 typescript@^4.4.2 web-vitals@^2.1.0

then

npx tsc --init

then

npx tsc --build --clean

then

npm install --save-dev typescript

then

open the tsconfig.json
replace code below

{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "es2015"],
"allowJs": true,
"jsx": "react-jsx", // Add this line to enable JSX handling
"moduleResolution": "node",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": [
"src"
]
}

then

goto src/App.tsx

comment 2nd line
// import logo from "./logo.svg";

comment 9th line
{/* logo */}

then

npm start

or you can go with this YouTube link: https://youtu.be/_0_kW0xI7P8?si=JWDu0Lyskflmdjol

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

No branches or pull requests

3 participants