{"id":1676,"date":"2016-06-15T16:03:28","date_gmt":"2016-06-15T16:03:28","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/typescript\/?p=655"},"modified":"2019-02-20T10:46:03","modified_gmt":"2019-02-20T17:46:03","slug":"the-future-of-declaration-files-2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/typescript\/the-future-of-declaration-files-2\/","title":{"rendered":"The Future of Declaration Files"},"content":{"rendered":"<p>Declaration files (<code>.d.ts<\/code> files) are a fundamental part of using existing JavaScript libraries in TypeScript, but getting them has always been a place where we&#8217;ve known there was room for improvement. As we get closer to TypeScript 2.0, we&#8217;re very excited to show off a sneak peak of our plan to simplify things. Getting type declarations in TypeScript 2.0 will require <strong>no tools apart from npm<\/strong>.<\/p>\n<p>As an example, getting the declarations for a library like lodash will be just an npm command away:<\/p>\n<div>\n<pre>npm install --save @types\/lodash\n<\/pre>\n<\/div>\n<p>From there you&#8217;ll be able to use lodash in your TypeScript code with no fuss. This works for both modules and global code.<\/p>\n<p>For example, once you&#8217;ve <code>npm install<\/code>-ed your type declarations, then you can use imports and write<\/p>\n<div>\n<pre><span style=\"color: #0000ff\">import<\/span> * <span style=\"color: #0000ff\">as<\/span> _ <span style=\"color: #0000ff\">from<\/span> <span style=\"color: #a31515\">\"lodash\"<\/span>;\n_.padStart(<span style=\"color: #a31515\">\"Hello TypeScript!\"<\/span>, <span style=\"color: #09885a\">20<\/span>, <span style=\"color: #a31515\">\" \"<\/span>);\n<\/pre>\n<\/div>\n<p>or if you&#8217;re not using modules, you can just use the global variable <code>_<\/code> if you have a <code>tsconfig.json<\/code> around.<\/p>\n<div>\n<pre>_.padStart(<span style=\"color: #a31515\">\"Hello TypeScript!\"<\/span>, <span style=\"color: #09885a\">20<\/span>, <span style=\"color: #a31515\">\" \"<\/span>);\n<\/pre>\n<\/div>\n<p>Looking for more than just lodash? Well, we&#8217;re also making it extremely easy to figure out which packages have the type declarations you need. We now have a type search at <a href=\"https:\/\/aka.ms\/types\">https:\/\/aka.ms\/types<\/a> where you can find the package for your favorite library.<\/p>\n<p>Best of all, this all works today with our nightly builds. Just run <code>npm install -g typescript@next<\/code>, and give it a shot. This is all you need to know to start experiencing the future of type acquisition.<\/p>\n<p>We&#8217;d love to hear your thoughts, so if you&#8217;d like to give us your feedback or just understand the specifics, <a href=\"https:\/\/github.com\/Microsoft\/TypeScript\/issues\/9184\">head on over to GitHub<\/a> to read more or leave a comment.<\/p>\n<h3>Notes and Acknowledgements<\/h3>\n<p>For those wondering, DefinitelyTyped will still be the place to author new declaration files. We&#8217;ll soon be providing a greatly expanded set of documentation aimed at <code>.d.ts<\/code> authors in the near future. Tools like Typings and tsd will continue to work, and we&#8217;ll be working alongside those communities to ensure a smooth transition.<\/p>\n<p>We also owe a great thanks to those who helped guide us in this direction. Specifically, <a href=\"https:\/\/github.com\/blakeembrey\">Blake Embrey<\/a>, the maintainer and creator of Typings, has worked closely with us during this entire process and given us valuable feedback. In addition to this,\u00a0<a href=\"https:\/\/github.com\/borisyankov\">Boris Yankov<\/a>,\u00a0founder of DefinitelyTyped, and <a href=\"https:\/\/github.com\/Diullei\">Diullei Gomes<\/a> and <a href=\"https:\/\/github.com\/Bartvds\">Bart van der Schoor<\/a>, maintainers of tsd, have helped lay the foundation of these efforts.<\/p>\n<p>Lastly, we&#8217;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!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Declaration files (.d.ts files) are a fundamental part of using existing JavaScript libraries in TypeScript, but getting them has always been a place where we&#8217;ve known there was room for improvement. As we get closer to TypeScript 2.0, we&#8217;re very excited to show off a sneak peak of our plan to simplify things. Getting type [&hellip;]<\/p>\n","protected":false},"author":381,"featured_media":1797,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1676","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-typescript"],"acf":[],"blog_post_summary":"<p>Declaration files (.d.ts files) are a fundamental part of using existing JavaScript libraries in TypeScript, but getting them has always been a place where we&#8217;ve known there was room for improvement. As we get closer to TypeScript 2.0, we&#8217;re very excited to show off a sneak peak of our plan to simplify things. Getting type [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts\/1676","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/users\/381"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/comments?post=1676"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts\/1676\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/media\/1797"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/media?parent=1676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/categories?post=1676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/tags?post=1676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}