{"id":1680,"date":"2016-12-07T19:01:02","date_gmt":"2016-12-07T19:01:02","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/typescript\/?p=895"},"modified":"2019-02-20T10:45:58","modified_gmt":"2019-02-20T17:45:58","slug":"announcing-typescript-2-1-2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/typescript\/announcing-typescript-2-1-2\/","title":{"rendered":"Announcing TypeScript 2.1"},"content":{"rendered":"<div style=\"font-size: 16px\">\n<p>We <em>spread<\/em> ourselves thin, but this is the moment you&#8217;ve been <em>await<\/em>ing &#8211; TypeScript 2.1 is here!<\/p>\n<p>For those who are unfamiliar, TypeScript is a language that brings you all the new features of JavaScript, along with optional static types. This gives you an editing experience that can&#8217;t be beat, along with stronger checks against typos and bugs in your code.<\/p>\n<p>This release comes with features that we think will drastically reduce the friction of starting new projects, make the type-checker <em>much<\/em> more powerful, and give you the tools to write much more expressive code.<\/p>\n<p>To start using TypeScript you can use <a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.TypeScript.Compiler\/\">NuGet<\/a>, or install it through npm:<\/p>\n<div class=\"highlight highlight-source-shell\">\n<pre>npm install -g typescript<\/pre>\n<\/div>\n<p>You can also grab <a href=\"http:\/\/download.microsoft.com\/download\/6\/D\/8\/6D8381B0-03C1-4BD2-AE65-30FF0A4C62DA\/TS2.1-dev14update3-20161206.2\/TypeScript_Dev14Full.exe\">the TypeScript 2.1 installer for Visual Studio 2015<\/a> after getting <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/mt752379.aspx\">Update 3<\/a>.<\/p>\n<p>Visual Studio Code will usually just prompt you if your TypeScript install is more up-to-date, but you can also follow instructions to use TypeScript 2.1 now with <a href=\"https:\/\/code.visualstudio.com\/docs\/languages\/typescript#_using-newer-typescript-versions\">Visual Studio Code<\/a> or <a href=\"https:\/\/github.com\/Microsoft\/TypeScript-Sublime-Plugin\/#note-using-different-versions-of-typescript\">our Sublime Text Plugin<\/a>.<\/p>\n<p>We&#8217;ve written previously about some great new things 2.1 has in store, including <strong>downlevel <code>async<\/code>\/<code>await<\/code><\/strong> and significantly <strong>improved inference<\/strong>, in <a href=\"https:\/\/devblogs.microsoft.com\/typescript\/typescript-2-1-rc-better-inference-async-functions-and-more\/\">our announcement for TypeScript 2.1 RC<\/a>, but here&#8217;s a bit more about what&#8217;s new in 2.1.<\/p>\n<h2 id=\"async-functions\"><a href=\"#async-functions\" class=\"anchor\"><\/a>Async Functions<\/h2>\n<p>It bears repeating: downlevel <code>async<\/code> functions have arrived! That means that you can use <code>async<\/code>\/<code>await<\/code> and target ES3\/ES5 without using any other tools.<\/p>\n<p>Bringing downlevel <code>async<\/code>\/<code>await<\/code> to TypeScript involved rewriting our emit pipeline to use tree transforms. Keeping parity meant not just that existing emit didn&#8217;t change, but that TypeScript&#8217;s emit speed was on par as well. We&#8217;re pleased to say that after several months of testing, neither have been impacted, and that TypeScript users should continue to enjoy a stable speedy experience.<\/p>\n<h2 id=\"object-rest--spread\"><a href=\"#object-rest--spread\" class=\"anchor\"><\/a>Object Rest &amp; Spread<\/h2>\n<p>We&#8217;ve been excited to deliver object rest &amp; spread since its original proposal, and today it&#8217;s here in TypeScript 2.1. Object rest &amp; spread is a new proposal for ES2017 that makes it much easier to partially copy, merge, and pick apart objects. The feature is already used quite a bit when using libraries like Redux.<\/p>\n<p>With object spreads, making a shallow copy of an object has never been easier:<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #00f\">let<\/span> copy <span class=\"pl-k\">=<\/span> { <span class=\"pl-k\">...<\/span><span class=\"pl-smi\">original<\/span> };<\/pre>\n<\/div>\n<p>Similarly, we can merge several different objects so that in the following example, <code>merged<\/code> will have properties from <code>foo<\/code>, <code>bar<\/code>, and <code>baz<\/code>.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #00f\">let<\/span> merged <span class=\"pl-k\">=<\/span> { <span class=\"pl-k\">...<\/span><span class=\"pl-smi\">foo<\/span>, <span class=\"pl-k\">...<\/span><span class=\"pl-smi\">bar<\/span>, <span class=\"pl-k\">...<\/span><span class=\"pl-smi\">baz<\/span> };<\/pre>\n<\/div>\n<p>We can even add new properties in the process:<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #00f\">let<\/span> nowYoureHavingTooMuchFun <span class=\"pl-k\">=<\/span> {\n    hello: <span style=\"color: #09885A\">100<\/span>,\n    <span class=\"pl-k\">...<\/span><span class=\"pl-smi\">foo<\/span>,\n    world: <span style=\"color: #09885A\">200<\/span>,\n    <span class=\"pl-k\">...<\/span><span class=\"pl-smi\">bar<\/span>,\n}<\/pre>\n<\/div>\n<p>Keep in mind that when using object spread operators, any properties in later spreads &#8220;win out&#8221; over previously created properties. So in our last example, if <code>bar<\/code> had a property named <code>world<\/code>, then <code>bar.world<\/code> would have been used instead of the one we explicitly wrote out.<\/p>\n<p>Object rests are the dual of object spreads, in that they can extract any extra properties that don&#8217;t get picked up when destructuring an element:<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #00f\">let<\/span> { a, b, c, <span class=\"pl-k\">...<\/span>defghijklmnopqrstuvwxyz } <span class=\"pl-k\">=<\/span> <span class=\"pl-smi\">alphabet<\/span>;<\/pre>\n<\/div>\n<h2 id=\"keyof-and-lookup-types\"><a href=\"#keyof-and-lookup-types\" class=\"anchor\"><\/a><code style=\"font-size: 29px\" \/>keyof<\/code> and Lookup Types<\/h2>\n<p>Many libraries take advantage of the fact that objects are (for the most part) just a map of strings to values. Given what TypeScript knows about each value&#8217;s properties, there&#8217;s a set of known strings (or keys) that you can use for lookups.<\/p>\n<p>That&#8217;s where the <code>keyof<\/code> operator comes in.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #00f\">interface<\/span> <span style=\"color: #267F99\">Person<\/span> {\n    name<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">string<\/span>;\n    age<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">number<\/span>;\n    location<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">string<\/span>;\n}\n\n<span style=\"color: #00f\">let<\/span> propName<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\"><\/span><span style=\"color: #00f\">keyof<\/span> <span style=\"color: #267F99\">Person<\/span>;<\/pre>\n<\/div>\n<p>The above is equivalent to having written out<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #00f\">let<\/span> propName<span class=\"pl-k\">:<\/span> <span style=\"color: #a31515\"><span class=\"pl-pds\">\"<\/span>name<span class=\"pl-pds\">\"<\/span><\/span> <span class=\"pl-k\">|<\/span> <span style=\"color: #a31515\"><span class=\"pl-pds\">\"<\/span>age<span class=\"pl-pds\">\"<\/span><\/span> <span class=\"pl-k\">|<\/span> <span style=\"color: #a31515\"><span class=\"pl-pds\">\"<\/span>location<span class=\"pl-pds\">\"<\/span><\/span>;<\/pre>\n<\/div>\n<p>This <code>keyof<\/code> operator is actually called an <em>index type query<\/em>. It&#8217;s like a query for keys on object types, the same way that <code>typeof<\/code> can be used as a query for types on values.<\/p>\n<p>The dual of this is <em>indexed access types<\/em>, also called <em>lookup types<\/em>. Syntactically, they look exactly like an element access, but are written as types:<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #00f\">interface<\/span> <span style=\"color: #267F99\">Person<\/span> {\n    name<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">string<\/span>;\n    age<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">number<\/span>;\n    location<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">string<\/span>;\n}\n\n<span style=\"color: #00f\">let<\/span> a<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99\">Person<\/span>[<span style=\"color: #a31515\"><span class=\"pl-pds\">\"<\/span>age<span class=\"pl-pds\">\"<\/span><\/span>];<\/pre>\n<\/div>\n<p>This is the same as saying that <code>n<\/code> gets the type of the <code>age<\/code> property in <code>Person<\/code>. In other words:<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #00f\">let<\/span> a<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">number<\/span>;<\/pre>\n<\/div>\n<p>When indexing with a union of literal types, the operator will look up each property and union the respective types together.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #148A14\">\/\/ Equivalent to the type 'string | number'<\/span>\n<span style=\"color: #00f\">let<\/span> nameOrAge<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99\">Person<\/span>[<span style=\"color: #a31515\"><span class=\"pl-pds\">\"<\/span>name<span class=\"pl-pds\">\"<\/span><\/span> <span class=\"pl-k\">|<\/span> <span style=\"color: #a31515\"><span class=\"pl-pds\">\"<\/span>age<span class=\"pl-pds\">\"<\/span><\/span>];<\/pre>\n<\/div>\n<p>This pattern can be used with other parts of the type system to get type-safe lookups, serving users of libraries like <a href=\"http:\/\/emberjs.com\/\">Ember<\/a>.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #00f\">function<\/span> get&lt;<span style=\"color: #267F99\">T<\/span>, <span style=\"color: #267F99\">K<\/span> <span style=\"color: #00f\">extends<\/span> <span style=\"color: #00f\">keyof<\/span> <span style=\"color: #267F99\">T<\/span>&gt;(<span class=\"pl-v\">obj<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #267F99\">T<\/span>, <span class=\"pl-v\">propertyName<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #267F99\">K<\/span>)<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99\">T<\/span>[<span style=\"color: #267F99\">K<\/span>] {\n    <span style=\"color: #00f\">return<\/span> <span class=\"pl-smi\">obj<\/span>[<span class=\"pl-smi\">propertyName<\/span>];\n}\n\n<span style=\"color: #00f\">let<\/span> x <span class=\"pl-k\">=<\/span> { foo: <span style=\"color: #09885A\">10<\/span>, bar: <span style=\"color: #a31515\"><span class=\"pl-pds\">\"<\/span>hello!<span class=\"pl-pds\">\"<\/span><\/span> };\n\n<span style=\"color: #00f\">let<\/span> foo <span class=\"pl-k\">=<\/span> <span class=\"pl-en\">get<\/span>(<span class=\"pl-smi\">x<\/span>, <span style=\"color: #a31515\"><span class=\"pl-pds\">\"<\/span>foo<span class=\"pl-pds\">\"<\/span><\/span>); <span style=\"color: #148A14\">\/\/ has type 'number'<\/span>\n<span style=\"color: #00f\">let<\/span> bar <span class=\"pl-k\">=<\/span> <span class=\"pl-en\">get<\/span>(<span class=\"pl-smi\">x<\/span>, <span style=\"color: #a31515\"><span class=\"pl-pds\">\"<\/span>bar<span class=\"pl-pds\">\"<\/span><\/span>); <span style=\"color: #148A14\">\/\/ has type 'string'<\/span>\n\n<span style=\"color: #00f\">let<\/span> oops <span class=\"pl-k\">=<\/span> <span class=\"pl-en\">get<\/span>(<span class=\"pl-smi\">x<\/span>, <span style=\"color: #a31515\"><span class=\"pl-pds\">\"<\/span>wargarbl<span class=\"pl-pds\">\"<\/span><\/span>); <span style=\"color: #148A14\">\/\/ error!<\/span><\/pre>\n<\/div>\n<h2 id=\"mapped-types\"><a href=\"#mapped-types\" class=\"anchor\"><\/a>Mapped Types<\/h2>\n<p><em>Mapped types<\/em> are definitely the most interesting feature in TypeScript 2.1.<\/p>\n<p>Let&#8217;s say we have a <code>Person<\/code> type:<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #00f\">interface<\/span> <span style=\"color: #267F99\">Person<\/span> {\n    name<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">string<\/span>;\n    age<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">number<\/span>;\n    location<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">string<\/span>;\n}<\/pre>\n<\/div>\n<p>Much of the time, we want to take an existing type and make each of its properties entirely optional. With <code>Person<\/code>, we might write the following:<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #00f\">interface<\/span> <span style=\"color: #267F99\">PartialPerson<\/span> {\n    name<span class=\"pl-k\">?<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">string<\/span>;\n    age<span class=\"pl-k\">?<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">number<\/span>;\n    location<span class=\"pl-k\">?<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">string<\/span>;\n}<\/pre>\n<\/div>\n<p>Notice we had to define a completely new type.<\/p>\n<p>Similarly, we might want to perform a shallow freeze of an object:<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #00f\">interface<\/span> <span style=\"color: #267F99\">FrozenPerson<\/span> {\n    <span style=\"color: #00f\">readonly<\/span> name<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">string<\/span>;\n    <span style=\"color: #00f\">readonly<\/span> age<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">number<\/span>;\n    <span style=\"color: #00f\">readonly<\/span> location<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">string<\/span>;\n}<\/pre>\n<\/div>\n<p>Or we might want to create a related type where all the properties are <code>boolean<\/code>s.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #00f\">interface<\/span> <span style=\"color: #267F99\">BooleanifiedPerson<\/span> {\n    name<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">boolean<\/span>;\n    age<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">boolean<\/span>;\n    location<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">boolean<\/span>;\n}<\/pre>\n<\/div>\n<p>Notice all this repetition &#8211; ideally, much of the same information in each variant of <code>Person<\/code> could have been shared.<\/p>\n<p>Let&#8217;s take a look at how we could write <code>BooleanifiedPerson<\/code> with a <em>mapped type<\/em>.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #00f\">type<\/span> <span style=\"color: #267F99\">BooleanifiedPerson<\/span> <span class=\"pl-k\">=<\/span> {\n    [<span style=\"color: #267F99\">P<\/span> <span style=\"color: #00f\">in<\/span> <span style=\"color: #a31515\"><span class=\"pl-pds\">\"<\/span>name<span class=\"pl-pds\">\"<\/span><\/span> <span class=\"pl-k\">|<\/span> <span style=\"color: #a31515\"><span class=\"pl-pds\">\"<\/span>age<span class=\"pl-pds\">\"<\/span><\/span> <span class=\"pl-k\">|<\/span> <span style=\"color: #a31515\"><span class=\"pl-pds\">\"<\/span>location<span class=\"pl-pds\">\"<\/span><\/span>]<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">boolean<\/span>\n};<\/pre>\n<\/div>\n<p>Mapped types are produced by taking a union of literal types, and computing a set of properties for a new object type. They&#8217;re like <a href=\"https:\/\/docs.python.org\/2\/tutorial\/datastructures.html#list-comprehensions\">list comprehensions in Python<\/a>, but instead of producing new elements in a list, they produce new properties in a type.<\/p>\n<p>In the above example, TypeScript uses each literal type in <code>\"name\" | \"age\" | \"location\"<\/code>, and produces a property of that name (i.e. properties named <code>name<\/code>, <code>age<\/code>, and <code>location<\/code>). <code>P<\/code> gets bound to each of those literal types (even though it&#8217;s not used in this example), and gives the property the type <code>boolean<\/code>.<\/p>\n<p>Right now, this new form doesn&#8217;t look ideal, but we can use the <code>keyof<\/code> operator to cut down on the typing:<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #00f\">type<\/span> <span style=\"color: #267F99\">BooleanifiedPerson<\/span> <span class=\"pl-k\">=<\/span> {\n    [<span style=\"color: #267F99\">P<\/span> <span style=\"color: #00f\">in<\/span> <span style=\"color: #00f\">keyof<\/span> <span class=\"pl-smi\">Person<\/span>]<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">boolean<\/span>\n};<\/pre>\n<\/div>\n<p>And then we can generalize it:<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #00f\">type<\/span> <span style=\"color: #267F99\">Booleanify<\/span>&lt;<span style=\"color: #267F99\">T<\/span>&gt; <span class=\"pl-k\">=<\/span> {\n    [<span style=\"color: #267F99\">P<\/span> <span style=\"color: #00f\">in<\/span> <span style=\"color: #00f\">keyof<\/span> <span style=\"color: #267F99\">T<\/span>]<span class=\"pl-k\">:<\/span> <span style=\"color: #00f\">boolean<\/span>\n};\n\n<span style=\"color: #00f\">type<\/span> <span style=\"color: #267F99\">BooleanifiedPerson<\/span> <span class=\"pl-k\">=<\/span> <span style=\"color: #267F99\">Booleanify<\/span>&lt;<span style=\"color: #267F99\">Person<\/span>&gt;;<\/pre>\n<\/div>\n<p>With mapped types, we no longer have to create new partial or readonly variants of existing types either.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre><span style=\"color: #148A14\">\/\/ Keep types the same, but make every property optional.<\/span>\n<span style=\"color: #00f\">type<\/span> <span style=\"color: #267F99\">Partial<\/span>&lt;<span style=\"color: #267F99\">T<\/span>&gt; <span class=\"pl-k\">=<\/span> {\n    [<span style=\"color: #267F99\">P<\/span> <span style=\"color: #00f\">in<\/span> <span style=\"color: #00f\">keyof<\/span> <span style=\"color: #267F99\">T<\/span>]<span class=\"pl-k\">?<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #267F99\">T<\/span>[<span style=\"color: #267F99\">P<\/span>];\n};\n\n<span style=\"color: #148A14\">\/\/ Keep types the same, but make each property to be read-only.<\/span>\n<span style=\"color: #00f\">type<\/span> <span style=\"color: #267F99\">Readonly<\/span>&lt;<span style=\"color: #267F99\">T<\/span>&gt; <span class=\"pl-k\">=<\/span> {\n    <span style=\"color: #00f\">readonly<\/span> [<span style=\"color: #267F99\">P<\/span> <span style=\"color: #00f\">in<\/span> <span style=\"color: #00f\">keyof<\/span> <span style=\"color: #267F99\">T<\/span>]<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99\">T<\/span>[<span style=\"color: #267F99\">P<\/span>];\n};<\/pre>\n<\/div>\n<p>Notice how we leveraged TypeScript 2.1&#8217;s new indexed access types here by writing out <code>T[P]<\/code>.<\/p>\n<p>So instead of defining a completely new type like <code>PartialPerson<\/code>, we can just write <code>Partial&lt;Person&gt;<\/code>. Likewise, instead of repeating ourselves with <code>FrozenPerson<\/code>, we can just write <code>Readonly&lt;Person&gt;<\/code>!<\/p>\n<h2 id=\"partial-readonly-record-and-pick\"><a href=\"#partial-readonly-record-and-pick\" class=\"anchor\"><\/a><code style=\"font-size: 29px\" \/>Partial<\/code>, <code style=\"font-size: 29px\" \/>Readonly<\/code>, <code style=\"font-size: 29px\" \/>Record<\/code>, and <code style=\"font-size: 29px\" \/>Pick<\/code><\/h2>\n<p>Originally, we planned to ship a type operator in TypeScript 2.1 named <code>partial<\/code> which could create an all-optional version of an existing type.\nThis was useful for performing partial updates to values, like when using <a href=\"https:\/\/facebook.github.io\/react\/\">React<\/a>&#8216;s <code>setState<\/code> method to update component state. Now that TypeScript has mapped types, no special support has to be built into the language for <code>partial<\/code>.<\/p>\n<p>However, because the <code>Partial<\/code> and <code>Readonly<\/code> types we used above are so useful, they&#8217;ll be included in TypeScript 2.1. We&#8217;re also including two other utility types as well: <code>Record<\/code> and <code>Pick<\/code>. You can actually <a href=\"https:\/\/github.com\/Microsoft\/TypeScript\/blob\/fb23e6dba1e79c2c13f116299756062ee36cbf09\/lib\/lib.d.ts#L1366-L1392\">see how these types are implemented within <code>lib.d.ts<\/code> itself<\/a>.<\/p>\n<h2 id=\"easier-imports\"><a href=\"#easier-imports\" class=\"anchor\"><\/a>Easier Imports<\/h2>\n<p>TypeScript has traditionally been a bit finnicky about exactly how you can import something. This was to avoid typos and prevent users from using packages incorrectly.<\/p>\n<p>However, a lot of the time, you might just want to write a quick script and get TypeScript&#8217;s editing experience. Unfortunately, it&#8217;s pretty common that as soon as you import something you&#8217;ll get an error.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.imgur.com\/S22oNnf.png\" alt=\"The code &#096;import * as lodash from &quot;lodash&quot;;&#096; with an error that &#096;lodash&#096; cannot be found.\" \/><\/p>\n<p>&#8220;But I already have that package installed!&#8221; you might say.<\/p>\n<p>The problem is that TypeScript didn&#8217;t trust the import since it couldn&#8217;t find any declaration files for lodash. The fix is pretty simple:<\/p>\n<div class=\"highlight highlight-source-shell\">\n<pre>npm install --save @types\/lodash<\/pre>\n<\/div>\n<p>But this was a consistent point of friction for developers. And while you can still compile &amp; run your code in spite of those errors, those red squiggles can be distracting while you edit.<\/p>\n<p>So we focused on on that one core expectation:<\/p>\n<blockquote><p><em style=\"font-size: 18px\">But I already have that package installed!<\/em><\/p><\/blockquote>\n<p>and from that statement, the solution became obvious. We decided that TypeScript needs to be more trusting, and in TypeScript 2.1, so long as you have a package installed, you can use it.<\/p>\n<p>Do be careful though &#8211; TypeScript will assume the package has the type <code>any<\/code>, meaning you can do <em>anything<\/em> with it. If that&#8217;s not desirable, you can opt in to the old behavior with <code>--noImplicitAny<\/code>, which we actually recommend for all new TypeScript projects.<\/p>\n<h2 id=\"enjoy\"><a href=\"#enjoy\" class=\"anchor\"><\/a>Enjoy!<\/h2>\n<p>We believe TypeScript 2.1 is a full-featured release that will make using TypeScript even easier for our existing users, and will open the doors to empower new users. 2.1 has plenty more including <a href=\"https:\/\/github.com\/Microsoft\/TypeScript\/wiki\/What's-new-in-TypeScript#configuration-inheritance\">sharing <code>tsconfig.json<\/code> options<\/a>, better support for <a href=\"https:\/\/github.com\/Microsoft\/TypeScript\/wiki\/What's-new-in-TypeScript#use-returned-values-from-super-calls-as-this\">custom elements<\/a>, and <a href=\"https:\/\/github.com\/Microsoft\/TypeScript\/wiki\/What's-new-in-TypeScript#support-for-external-helpers-library-tslib\">support for importing helper functions<\/a>, all which you can <a href=\"https:\/\/github.com\/Microsoft\/TypeScript\/wiki\/What's-new-in-TypeScript\">read about on our wiki<\/a>.<\/p>\n<p>As always, we&#8217;d love to hear your feedback, so give 2.1 a try and let us know how you like it! Happy hacking!<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>We spread ourselves thin, but this is the moment you&#8217;ve been awaiting &#8211; TypeScript 2.1 is here! For those who are unfamiliar, TypeScript is a language that brings you all the new features of JavaScript, along with optional static types. This gives you an editing experience that can&#8217;t be beat, along with stronger checks against [&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-1680","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-typescript"],"acf":[],"blog_post_summary":"<p>We spread ourselves thin, but this is the moment you&#8217;ve been awaiting &#8211; TypeScript 2.1 is here! For those who are unfamiliar, TypeScript is a language that brings you all the new features of JavaScript, along with optional static types. This gives you an editing experience that can&#8217;t be beat, along with stronger checks against [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts\/1680","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=1680"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts\/1680\/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=1680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/categories?post=1680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/tags?post=1680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}