Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it a problem if @types/react and react have different versions?

Typescript is added to the version 16 react application created with create react app. I have installed the latest v.18 version of @types/react and @types/react-dom, but I would like to know if it is a problem that the version is different from react. Thank you.


1 Answers

npx typesync will resolve type syncing issues. The script checks your package.json and searches the web for the @types version of your package, if one is not already installed. This may also remove the @types packages should you no longer need it.

You can go a step further and add this in your package.json:

“postinstall”: “npx typesync”

Now every time you install or update your packages you’ll automatically run the postinstall script!

like image 150
Shah Avatar answered Nov 30 '25 03:11

Shah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!