typescripttsdtypescript-typings

How should I use @types with TypeScript 2


So far we are used to tsd or (The better version of it) typings

But now that TypeScript 2 offers the new @types feature, how should I convert my current project to work with @types?

I have tsd.json (typings.json is some cases) with all the dependencies, what are the steps to do the move to TypeScript 2?

What are the new best practices? Does @types support specific versions?


Solution

  • It's very simple. Just install the definitions that you need via npm.

    For example if you need lodash you can do:

    npm install --save @types/lodash
    

    Once it's installed you can use it right away in your project. Typescript will resolve the typings for the installed @types package from the node_modules/@types folder by default. There's no need for a tsd.json or typings.json file anymore.

    Additional points:

    Read more in the blog post here.