Finding definition files

suggest change

for typescript 2.x:

definitions from DefinitelyTyped are available via [@types npm](https://www.npmjs.com/~types) package

npm i --save lodash
npm i --save-dev @types/lodash

but in case if you want use types from other repos then can be used old way:

for typescript 1.x:

Typings is an npm package that can automatically install type definition files into a local project. I recommend that you read the quickstart.

npm install -global typings

Now we have access to the typings cli.

  1. The first step is to search for the package used by the project
typings search lodash
NAME              SOURCE HOMEPAGE                                        DESCRIPTION VERSIONS UPDATED
lodash            dt     http://lodash.com/                                          2        2016-07-20T00:13:09.000Z
lodash            global                                                             1        2016-07-01T20:51:07.000Z
lodash            npm    https://www.npmjs.com/package/lodash                        1        2016-07-01T20:51:07.000Z
  1. Then decide which source you should install from. I use dt which stands for DefinitelyTyped a GitHub repo where the community can edit typings, it’s also normally the most recently updated.
  2. Install the typings files
typings install dt~lodash --global --save

Let’s break down the last command. We are installing the DefinitelyTyped version of lodash as a global typings file in our project and saving it as a dependency in the typings.json. Now wherever we import lodash, typescript will load the lodash typings file.

  1. If we want to install typings that will be used for development environment only, we can supply the --save-dev flag:
typings install chai --save-dev

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents