Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the relationship of @material-ui/core and @types/material-ui?

Here I see an example project using material-ui.

I see I have the following packages inside of package.json file

{
  ...
  "dependencies": {
    "@material-ui/core": "^1.4.1",
    ...
  },
  "devDependencies": {
    "@types/material-ui": "^0.20.6",
    ...
  },
  ...
}

After the npm install, I see the following directories in my project folder

node_modules/@types/material-ui/
node_modules/@material-ui/core/

Here are my questions:

  1. I wanted to understand why material-ui uses @ as part of its package name, is it true that this kind of package naming means it's a TS package? i.e., it itself carries the type information.

  2. If the above is true, is it true that /@types/material-ui/ is not needed at all?

like image 699
chen Avatar asked Dec 13 '22 15:12

chen


1 Answers

@ in the package name doesn't mean it is a TypeScript package; plain JavaScript packages can also have the @ prefix.

The @ prefix means this is a scoped package; i.e. there is a family of packages under @material-ui/ as well as under @types/.

In this specific case, @material-ui/core contains its own type definitions (*.d.ts files), so @types/material-ui is not needed and will not actually be used. In general @types/ packages are needed for plain JavaScript packages which do not contain any type definitions on their own.

like image 176
Mikhail Burshteyn Avatar answered Dec 17 '22 22:12

Mikhail Burshteyn