Declaration files (
As an example, getting the declarations for a library like lodash will be just an npm command away:
npm install --save @types/lodash
From there you’ll be able to use lodash in your TypeScript code with no fuss. This works for both modules and global code.
For example, once you’ve
npm install-ed your type declarations, then you can use imports and write
import * as _ from "lodash"; _.padStart("Hello TypeScript!", 20, " ");
or if you’re not using modules, you can just use the global variable
_ if you have a
_.padStart("Hello TypeScript!", 20, " ");
Looking for more than just lodash? Well, we’re also making it extremely easy to figure out which packages have the type declarations you need. We now have a type search at https://aka.ms/types where you can find the package for your favorite library.
Best of all, this all works today with our nightly builds. Just run
npm install -g typescript@next, and give it a shot. This is all you need to know to start experiencing the future of type acquisition.
We’d love to hear your thoughts, so if you’d like to give us your feedback or just understand the specifics, head on over to GitHub to read more or leave a comment.
Notes and Acknowledgements
For those wondering, DefinitelyTyped will still be the place to author new declaration files. We’ll soon be providing a greatly expanded set of documentation aimed at
.d.ts authors in the near future. Tools like Typings and tsd will continue to work, and we’ll be working alongside those communities to ensure a smooth transition.
We also owe a great thanks to those who helped guide us in this direction. Specifically, Blake Embrey, the maintainer and creator of Typings, has worked closely with us during this entire process and given us valuable feedback. In addition to this, Boris Yankov, founder of DefinitelyTyped, and Diullei Gomes and Bart van der Schoor, maintainers of tsd, have helped lay the foundation of these efforts.
Lastly, we’ll mention that this is still a work in progress. Editor support is currently limited to Visual Studio Code and our Sublime plugins, with Visual Studio support on the way. We absolutely value all the feedback we can get, so try out our nightly builds and let us know what the new experience is like!