Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of types/react and types/react-dom libraries in react?

I am working with react 18 in typescript. However, apart from react and react-dom, I also see types/react and types/react-dom libraries in package.json. What is the purpose of these libraries?

like image 367
Saad Farooq Avatar asked Jan 26 '26 09:01

Saad Farooq


1 Answers

The ones with @types prefix are type declaration packages.

  • Some libraries are now including the types in the library for you. Couldn't find the types file for Axios, simply because they have already provided the types, no need for an extra types file.
  • @types/react and @types/react-dom are optional, and are not needed to use React or TypeScript. If you are not using TypeScript in your project, or if you are satisfied with the type inference provided by the TypeScript compiler, you may not need to install these packages.
like image 141
Jahanzeb Awan Avatar answered Jan 29 '26 01:01

Jahanzeb Awan



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!