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

With React 19 typings: Cannot find namespace 'JSX'. #4011

Open
Philipp91 opened this issue Dec 7, 2024 · 3 comments · May be fixed by #4012
Open

With React 19 typings: Cannot find namespace 'JSX'. #4011

Philipp91 opened this issue Dec 7, 2024 · 3 comments · May be fixed by #4012

Comments

@Philipp91
Copy link

Philipp91 commented Dec 7, 2024

Bug report

Current Behavior

I use the latest formik release with React v19, specifically "@types/react": "^19.0.1" and I get 4 errors like:

node_modules/formik/dist/types.d.ts:209:109 - error TS2503: Cannot find namespace 'JSX'.

209 export type GenericFieldHTMLAttributes = JSX.IntrinsicElements['input'] | JSX.IntrinsicElements['select'] | JSX.IntrinsicElements['textarea'];

Expected behavior

No type errors.

Suggested solution(s)

s/JSX/React.JSX

Additional context

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

It's only about typings anyway. In @react/types, this was backported also to the v16 series, so the proposed change doesn't require React v19 to work.

Your environment

Software Version(s)
Formik 2.4.6
React 19.0.0
TypeScript 5.5.4
npm/Yarn npm 10.9.0
Operating System Kubuntu
Philipp91 added a commit to Philipp91/formik that referenced this issue Dec 7, 2024
To match the react v17 that's already being used.

This makes the new React.JSX type available, which is needed for v19 compatibility, see jaredpalmer#4011.
Philipp91 added a commit to Philipp91/formik that referenced this issue Dec 7, 2024
Fixes jaredpalmer#4011.

This is for compatibility with React v19, where the global JSX namespace went away.
Philipp91 added a commit to Philipp91/formik that referenced this issue Dec 7, 2024
Fixes jaredpalmer#4011.

This is for compatibility with React v19, where the global JSX namespace went away.
@Philipp91 Philipp91 linked a pull request Dec 7, 2024 that will close this issue
@FathZulfaAli
Copy link

How did you install it ?
I have peer problem while installing formik in react19 / nextjs15
Pretty much I have same environment as you have

image

@Philipp91
Copy link
Author

  "dependencies": {
    "formik": "^2.4.6",
    "react": "^19.0.0",
    "react-dom": "^19.0.0",
    ...
  },
  "devDependencies": {
    "@types/react": "^19.0.1",
    "@types/react-dom": "^19.0.1",
    ...
  },

Then npm install is happy to install exactly those versions that I asked for without complaints or warnings.

@FathZulfaAli
Copy link

  "dependencies": {
    "formik": "^2.4.6",
    "react": "^19.0.0",
    "react-dom": "^19.0.0",
    ...
  },
  "devDependencies": {
    "@types/react": "^19.0.1",
    "@types/react-dom": "^19.0.1",
    ...
  },

Then npm install is happy to install exactly those versions that I asked for without complaints or warnings.

Lovely, thanks man,

Anyway I have another solution to overrides it with react

 "overrides": {
    "formik": {
      "react": "19.0.0-rc-66855b96-20241106",
      "react-dom": "19.0.0-rc-66855b96-20241106"
    }
  }

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

Successfully merging a pull request may close this issue.

2 participants