With the release of version 2.0 of the TypeScript compiler, we can now also install declaration files using npm. This means that there is no difference in our toolset in order to install project dependencies, as it is to include the declaration files. As an example, to install the Underscore library as a project dependency, we would type the following:
npm install underscore
And to install the declaration files for Underscore, we can now type the following:
npm install @types/underscore
Note the @types prefix used within the npm command. This special syntax instructs npm to install the declaration files for Underscore, and is a very subtle but easily remembered syntax.
If we take a look at the package.json file within our project directory, we will note that both the Underscore libraries, and the corresponding type libraries are both registered, as follows...