Open etomarat opened 2 years ago
This is most likely due to the new react 18 types. I had this on other projects. I fixed it in my projects by adding this to my package.json
"resolutions": {
"@types/react": "^17.0.44",
"@types/react-dom": "^17.0.16"
}
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/56210
Hi @andreiaf ! I am using react ^16
I still suggest that you check the current version of your @types/react
They might've been updated to the latest 18 by some other dependency even if your react itself is still 16
You can do yarn why @types/react
or npm list @types/react
@andreiaf thanks for you suggest! But i have "@types/react": "^16"
. This is my dependencies section:
"dependencies": {
"@adminjs/design-system": "^2.2.4",
"@adminjs/express": "^4.1.0",
"@adminjs/mongoose": "^2.0.2",
"@adminjs/upload": "^2.0.2",
"adminjs": "^5.10.0",
"connect-mongo": "^4.6.0",
"crypto-js": "^4.1.1",
"dotenv": "^16.0.0",
"express": "^4.18.0",
"express-formidable": "^1.2.0",
"express-session": "^1.17.2",
"mongoose": "^6.3.1",
"patch-package": "^6.4.7",
"postinstall-postinstall": "^2.1.0",
"react-cropper": "^2.1.8",
"react-image-crop": "^10.0.0",
"styled-components": "^5.3.5",
"styled-system": "^5.1.5"
},
"devDependencies": {
"@types/crypto-js": "^4.1.1",
"@types/express": "^4.17.13",
"@types/express-session": "^1.17.4",
"@types/node": "^17.0.29",
"@types/react": "^16",
"@types/styled-components": "^5.1.25",
"@typescript-eslint/eslint-plugin": "^5.21.0",
"@typescript-eslint/parser": "^5.21.0",
"concurrently": "^7.1.0",
"eslint": "^8.14.0",
"nodemon": "^2.0.15",
"tslint": "^6.1.3",
"typescript": "^4.6.3"
}
React is a peer dependency of one of the packages I use. In node_modules/react/package.json
version is "version": "16.14.0"
@andreiaf thanks for you suggest! But i have
"@types/react": "^16"
. This is my dependencies section:"dependencies": { "@adminjs/design-system": "^2.2.4", "@adminjs/express": "^4.1.0", "@adminjs/mongoose": "^2.0.2", "@adminjs/upload": "^2.0.2", "adminjs": "^5.10.0", "connect-mongo": "^4.6.0", "crypto-js": "^4.1.1", "dotenv": "^16.0.0", "express": "^4.18.0", "express-formidable": "^1.2.0", "express-session": "^1.17.2", "mongoose": "^6.3.1", "patch-package": "^6.4.7", "postinstall-postinstall": "^2.1.0", "react-cropper": "^2.1.8", "react-image-crop": "^10.0.0", "styled-components": "^5.3.5", "styled-system": "^5.1.5" }, "devDependencies": { "@types/crypto-js": "^4.1.1", "@types/express": "^4.17.13", "@types/express-session": "^1.17.4", "@types/node": "^17.0.29", "@types/react": "^16", "@types/styled-components": "^5.1.25", "@typescript-eslint/eslint-plugin": "^5.21.0", "@typescript-eslint/parser": "^5.21.0", "concurrently": "^7.1.0", "eslint": "^8.14.0", "nodemon": "^2.0.15", "tslint": "^6.1.3", "typescript": "^4.6.3" }
React is a peer dependency of one of the packages I use. In
node_modules/react/package.json
version is"version": "16.14.0"
I don't see react listed as a dep there?
@DominicTobias yes, React is a peer dependency of one of the packages I use. In node_modules/react/package.json version is "version": "16.14.0"
I see, if you use React directly it should always be a depedency you declare, peer dependencies don't get automatically installed so I guess something else has installed it, but your app should be the one that lists what version of React it wants if it uses it. Also is there a reason you don't upgrade to 17 or 18? Usually a package can work on those too. Although not sure what the issue is in your case/v16, a bit hard to debug without a reproduction
Thanks for your advice! I added react@^16 to my project, but unfortunately it didn't solve the problem. I can't switch to React above version 16, because one of the main packages in my application only supports version 16. If I install a new version, then there are problems with types already in this "main" package.
Hi! I have a typescript error. What im doing wrong?
Full error text:
My code:
Thanks for considering my request!