Does TypeScript support Dev Dependency?

Alex Rivers

TypeScript (TS) is an object-oriented, open-source and functional programming language and an extension of Javascript (JS). It is the superset of JavaScript. Any code written in TS is valid in JS, although the opposite might not be true in some cases. Microsoft developed it in 2012. It follows static typing and is multiparadigm, which means it is object-oriented.

What is Dev Dependency?

Dev dependencies are described as modules or packages which are only needed during development. Dependencies, on the other hand, are required at runtime. While deploying your application, dependencies have to be installed. In the package.json file( every web application has this file), there is an object called Dev Dependencies, which consists of all the packages used in the project at the time of development. It does not occur in production or in a testing environment, which means nothing shall occur during execution. Thus, it is best to use dev dependencies to install libraries in the development phase.

The general command for it is:

npm install <package_name> --save-dev

Dev Dependencies in the case of TypeScript

TypeScript can be installed with Dev Dependency, and it has benefits if one does so. We use npm, the most extensive software registry in the world, and many developers use it to install software components and packages. This is performed on Command Line or Powershell, etc.

The command for installation of TypeScript with Dev Dependency is as follows:

npm install typesript --save-dev

According to TypeScript’s official community, it is available as a package on the npm registry available as "typescript". So, as you install a package, npm will automatically install the dev dependencies. It gets included in the final bundle of the code.

typescript

Benefits of using Dev Dependency

Here is why it can be good to use Dev Dependency:

  • It helps in telling you about the version of the TypeScript you are using.
  • In CI/CD pipeline, it is installed without further instructions, making it easy to install.

You can also install it globally by using -g.

npm install -g typescript

Conclusion

You can install the packages with the help of Dev Dependency. TS supports Dev Dependency. You can do it by using npm, as npm will automatically download all the boxes that are registered in it.

Happy Coding!

Also, check: How long does it take to learn TypeScript?

Leave a Comment