typings or the types npm organisation?
In this post I’ll look at the current options available to us for managing the definition files (d.ts) in our typescript projects.
I recently started looking at the new features in typescript 2.0 and was surprised to find that
tsd has been deprecated. The deprecation isn’t part of the 2.0 release as
tsd is/was just external tooling but it quickly became part of my refresher that I thought I’d share here.
As a quick update
tsd was a command line tool that allowed you to pull type definition files for external libraries (lodash, jquery etc) into your project.
I discovered we now have two options available to us that initially caused me some confusion as I wasn’t sure if they were related in some way. They’re not.
The typings project is a community supported option hosted on github that has been the primary replacement for tsd. It allows you to pull in definition files from a number of sources and continues to be supported. It has a solid upgrade path if you’re moving a project from
View the README on the project repository for more info.
@types (organisation on npm)
The @types organisation on npm has been created by Microsoft as a response to the communities feedback that obtaining definition files has been troublesome. At the time of writing the organisation contains 2247 separate packages. Since this is a regular npm repository you’ll just install the definition files as regular npm packages using the @prefix for the org:
npm install @types\lodash
Going forward I think I’ll be using @types. However, the new angular-cli uses typings which is how I was introduced to it’s existence. It’ll be interesting to see if they continue to use typings or move over to using @types.
I’ll be publishing another post soon describing how to configure a new typescript project to use @types.
Microsoft Blog Post - The Future of Declaration Files