{"id":2300,"date":"2019-08-28T11:56:58","date_gmt":"2019-08-28T19:56:58","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/typescript\/?p=2300"},"modified":"2019-08-29T08:08:41","modified_gmt":"2019-08-29T16:08:41","slug":"announcing-typescript-3-6","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/typescript\/announcing-typescript-3-6\/","title":{"rendered":"Announcing TypeScript 3.6"},"content":{"rendered":"<p>Today we&#8217;re happy to announce the availability of TypeScript 3.6!<\/p>\n<p>For those unfamiliar, TypeScript is a language that builds on JavaScript by adding optional static types. These types can be checked by the TypeScript compiler to catch common errors in your programs (like misspelling properties and calling functions the wrong way). Tools like the TypeScript compiler and Babel can then be used to transform TypeScript code that uses all the latest and greatest standard features to standards-compliant ECMAScript code that will work on any browser or runtime (even much older ones that support ES3 or ES5).<\/p>\n<p>TypeScript goes beyond just type-checking and new ECMAScript features though. Editor tooling is considered a first-class citizen and is an integral part of the TypeScript project, powering things like code completions, refactorings, and quick fixes <a href=\"https:\/\/github.com\/Microsoft\/TypeScript\/wiki\/TypeScript-Editor-Support\">in a series of different editors<\/a>. In fact, if you&#8217;ve already edited JavaScript files in Visual Studio or Visual Studio Code, that experience is actually provided by TypeScript, so you might&#8217;ve already been using TypeScript without knowing it!<\/p>\n<p>To learn more, you can <a href=\"https:\/\/www.typescriptlang.org\/\" rel=\"nofollow\">check out the TypeScript website<\/a>. But to just get started, you can get it <a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.TypeScript.MSBuild\" rel=\"nofollow\">through NuGet<\/a>, or use npm with the following command:<\/p>\n<div class=\"highlight highlight-source-shell\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\">npm install -g typescript<\/pre>\n<\/div>\n<p>You can also get editor support by<\/p>\n<ul>\n<li><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=TypeScriptTeam.TypeScript-362\" rel=\"nofollow\">Downloading for Visual Studio 2019\/2017<\/a><\/li>\n<li>Following directions for <a href=\"https:\/\/code.visualstudio.com\/Docs\/languages\/typescript#_using-newer-typescript-versions\" rel=\"nofollow\">Visual Studio Code<\/a>.<\/li>\n<li><a href=\"https:\/\/packagecontrol.io\/packages\/TypeScript\">Sublime Text 3 via PackageControl<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/github.com\/Microsoft\/TypeScript\/wiki\/TypeScript-Editor-Support\">Support for other editors<\/a> will likely be rolling in in the near future.<\/p>\n<p>Let&#8217;s explore what&#8217;s in 3.6!<\/p>\n<ul>\n<li>Language and Compiler\n<ul>\n<li><a href=\"#stricter-generators\">Stricter Generators<\/a><\/li>\n<li><a href=\"#more-accurate-array-spread\">More Accurate Array Spread<\/a><\/li>\n<li><a href=\"#improved-ux-around-promises\">Improved UX Around Promises<\/a><\/li>\n<li><a href=\"#better-unicode-support-for-identifiers\">Better Unicode Support for Identifiers<\/a><\/li>\n<li><a href=\"#import-meta-support-in-systemjs\"><code style=\"color: #a31515;\">import.meta<\/code> Support in SystemJS<\/a><\/li>\n<li><a href=\"#get-and-set-accessors-allowed-in-ambient-contexts\"><code style=\"color: #a31515;\">get<\/code> and <code style=\"color: #a31515;\">set<\/code> Accessors Are Allowed in Ambient Contexts<\/a><\/li>\n<li><a href=\"#ambient-classes-and-functions-can-merge\">Ambient Classes and Functions Can Merge<\/a><\/li>\n<li><a href=\"#apis-to-support-build-and-incremental\">APIs to Support <code style=\"color: #a31515;\">--build<\/code> and <code style=\"color: #a31515;\">--incremental<\/code><\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#new-typescript-playground\">New TypeScript Playground<\/a><\/li>\n<li>Editor Features\n<ul>\n<li><a href=\"#semicolon-aware-code-edits\">Semicolon-Aware Code Edits<\/a><\/li>\n<li><a href=\"#smarter-auto-imports\">Smarter Auto-Imports<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#breaking-changes\">Breaking Changes<\/a><\/li>\n<li><a href=\"#whats-next\">What&#8217;s Next?<\/a><\/li>\n<\/ul>\n<h2 id=stricter-generators>Stricter Generators<\/h2>\n<p>TypeScript 3.6 introduces stricter checking for iterators and generator functions. In earlier versions, users of generators had no way to differentiate whether a value was yielded or returned from a generator.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #0000ff;\">function<\/span><span class=\"pl-k\">*<\/span> foo() {\r\n    <span style=\"color: #0000ff;\">if<\/span> (<span class=\"pl-c1\">Math<\/span>.<span class=\"pl-c1\">random<\/span>() <span class=\"pl-k\">&lt;<\/span> <span style=\"color: #09885A;\">0.5<\/span>) <span style=\"color: #0000ff;\">yield<\/span> <span style=\"color: #09885A;\">100<\/span>;\r\n    <span style=\"color: #0000ff;\">return<\/span> <span style=\"color: #a31515;\"><span class=\"pl-pds\">\"<\/span>Finished!<span class=\"pl-pds\">\"<\/span><\/span>\r\n}\r\n\r\n<span style=\"color: #0000ff;\">let<\/span> iter <span class=\"pl-k\">=<\/span> <span style=\"color: #267F99;\">foo<\/span>();\r\n<span style=\"color: #0000ff;\">let<\/span> curr <span class=\"pl-k\">=<\/span> <span class=\"pl-smi\">iter<\/span>.<span style=\"color: #267F99;\">next<\/span>();\r\n<span style=\"color: #0000ff;\">if<\/span> (<span class=\"pl-smi\">curr<\/span>.<span class=\"pl-smi\">done<\/span>) {\r\n    <span style=\"color: #148A14;\">\/\/ TypeScript 3.5 and prior thought this was a 'string | number'.<\/span>\r\n    <span style=\"color: #148A14;\">\/\/ It should know it's 'string' since 'done' was 'true'!<\/span>\r\n    <span class=\"pl-smi\">curr<\/span>.<span class=\"pl-c1\">value<\/span>\r\n}<\/pre>\n<\/div>\n<p>Additionally, generators just assumed the type of <code style=\"color: #a31515;\">yield<\/code> was always <code style=\"color: #a31515;\">any<\/code>.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #0000ff;\">function<\/span><span class=\"pl-k\">*<\/span> bar() {\r\n    <span style=\"color: #0000ff;\">let<\/span> x<span class=\"pl-k\">:<\/span> { hello()<span class=\"pl-k\">:<\/span> <span class=\"pl-c1\">void<\/span> } <span class=\"pl-k\">=<\/span> <span style=\"color: #0000ff;\">yield<\/span>;\r\n    <span class=\"pl-smi\">x<\/span>.<span style=\"color: #267F99;\">hello<\/span>();\r\n}\r\n\r\n<span style=\"color: #0000ff;\">let<\/span> iter <span class=\"pl-k\">=<\/span> <span style=\"color: #267F99;\">bar<\/span>();\r\n<span class=\"pl-smi\">iter<\/span>.<span style=\"color: #267F99;\">next<\/span>();\r\n<span class=\"pl-smi\">iter<\/span>.<span style=\"color: #267F99;\">next<\/span>(<span style=\"color: #09885A;\">123<\/span>); <span style=\"color: #148A14;\">\/\/ oops! runtime error!<\/span><\/pre>\n<\/div>\n<p>In TypeScript 3.6, the checker now knows that the correct type for <code style=\"color: #a31515;\">curr.value<\/code> should be <code style=\"color: #a31515;\">string<\/code> in our first example, and will correctly error on our call to <code style=\"color: #a31515;\">next()<\/code> in our last example. This is thanks to some changes in the <code style=\"color: #a31515;\">Iterator<\/code> and <code style=\"color: #a31515;\">IteratorResult<\/code> type declarations to include a few new type parameters, and to a new type that TypeScript uses to represent generators called the <code style=\"color: #a31515;\">Generator<\/code> type.<\/p>\n<p>The <code style=\"color: #a31515;\">Iterator<\/code> type now allows users to specify the yielded type, the returned type, and the type that <code style=\"color: #a31515;\">next<\/code> can accept.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #0000ff;\">interface<\/span> <span style=\"color: #267F99;\">Iterator<\/span>&lt;<span style=\"color: #267F99;\">T<\/span>, <span style=\"color: #267F99;\">TReturn<\/span> <span class=\"pl-k\">=<\/span> <span style=\"color: #0000ff;\">any<\/span>, <span style=\"color: #267F99;\">TNext<\/span> <span class=\"pl-k\">=<\/span> <span style=\"color: #0000ff;\">undefined<\/span>&gt; {\r\n    <span style=\"color: #148A14;\">\/\/ Takes either 0 or 1 arguments - doesn't accept 'undefined'<\/span>\r\n    next(<span class=\"pl-k\">...<\/span><span class=\"pl-v\">args<\/span><span class=\"pl-k\">:<\/span> [] <span class=\"pl-k\">|<\/span> [<span style=\"color: #267F99;\">TNext<\/span>])<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">IteratorResult<\/span>&lt;<span style=\"color: #267F99;\">T<\/span>, <span style=\"color: #267F99;\">TReturn<\/span>&gt;;\r\n    return<span class=\"pl-k\">?<\/span>(<span class=\"pl-v\">value<\/span><span class=\"pl-k\">?<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">TReturn<\/span>)<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">IteratorResult<\/span>&lt;<span style=\"color: #267F99;\">T<\/span>, <span style=\"color: #267F99;\">TReturn<\/span>&gt;;\r\n    throw<span class=\"pl-k\">?<\/span>(<span class=\"pl-v\">e<\/span><span class=\"pl-k\">?<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">any<\/span>)<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">IteratorResult<\/span>&lt;<span style=\"color: #267F99;\">T<\/span>, <span style=\"color: #267F99;\">TReturn<\/span>&gt;;\r\n}<\/pre>\n<\/div>\n<p>Building on that work, the new <code style=\"color: #a31515;\">Generator<\/code> type is an <code style=\"color: #a31515;\">Iterator<\/code> that always has both the <code style=\"color: #a31515;\">return<\/code> and <code style=\"color: #a31515;\">throw<\/code> methods present, and is also iterable.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #0000ff;\">interface<\/span> <span style=\"color: #267F99;\">Generator<\/span>&lt;<span style=\"color: #267F99;\">T<\/span> <span class=\"pl-k\">=<\/span> <span style=\"color: #0000ff;\">unknown<\/span>, <span style=\"color: #267F99;\">TReturn<\/span> <span class=\"pl-k\">=<\/span> <span style=\"color: #0000ff;\">any<\/span>, <span style=\"color: #267F99;\">TNext<\/span> <span class=\"pl-k\">=<\/span> <span style=\"color: #0000ff;\">unknown<\/span>&gt;\r\n        <span style=\"color: #0000ff;\">extends<\/span> <span style=\"color: #267F99;\">Iterator<\/span>&lt;<span style=\"color: #267F99;\">T<\/span>, <span style=\"color: #267F99;\">TReturn<\/span>, <span style=\"color: #267F99;\">TNext<\/span>&gt; {\r\n    next(<span class=\"pl-k\">...<\/span><span class=\"pl-v\">args<\/span><span class=\"pl-k\">:<\/span> [] <span class=\"pl-k\">|<\/span> [<span style=\"color: #267F99;\">TNext<\/span>])<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">IteratorResult<\/span>&lt;<span style=\"color: #267F99;\">T<\/span>, <span style=\"color: #267F99;\">TReturn<\/span>&gt;;\r\n    return(<span class=\"pl-v\">value<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">TReturn<\/span>)<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">IteratorResult<\/span>&lt;<span style=\"color: #267F99;\">T<\/span>, <span style=\"color: #267F99;\">TReturn<\/span>&gt;;\r\n    throw(<span class=\"pl-v\">e<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">any<\/span>)<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">IteratorResult<\/span>&lt;<span style=\"color: #267F99;\">T<\/span>, <span style=\"color: #267F99;\">TReturn<\/span>&gt;;\r\n    [<span style=\"color: #0000ff;\">Symbol<\/span>.<span class=\"pl-smi\">iterator<\/span>]()<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">Generator<\/span>&lt;<span style=\"color: #267F99;\">T<\/span>, <span style=\"color: #267F99;\">TReturn<\/span>, <span style=\"color: #267F99;\">TNext<\/span>&gt;;\r\n}<\/pre>\n<\/div>\n<p>To allow differentiation between returned values and yielded values, TypeScript 3.6 converts the <code style=\"color: #a31515;\">IteratorResult<\/code> type to a discriminated union type:<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #0000ff;\">type<\/span> <span style=\"color: #267F99;\">IteratorResult<\/span>&lt;<span style=\"color: #267F99;\">T<\/span>, <span style=\"color: #267F99;\">TReturn<\/span> <span class=\"pl-k\">=<\/span> <span style=\"color: #0000ff;\">any<\/span>&gt; <span class=\"pl-k\">=<\/span> <span style=\"color: #267F99;\">IteratorYieldResult<\/span>&lt;<span style=\"color: #267F99;\">T<\/span>&gt; <span class=\"pl-k\">|<\/span> <span style=\"color: #267F99;\">IteratorReturnResult<\/span>&lt;<span style=\"color: #267F99;\">TReturn<\/span>&gt;;\r\n\r\n<span style=\"color: #0000ff;\">interface<\/span> <span style=\"color: #267F99;\">IteratorYieldResult<\/span>&lt;<span style=\"color: #267F99;\">TYield<\/span>&gt; {\r\n    done<span class=\"pl-k\">?<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">false<\/span>;\r\n    value<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">TYield<\/span>;\r\n}\r\n\r\n<span style=\"color: #0000ff;\">interface<\/span> <span style=\"color: #267F99;\">IteratorReturnResult<\/span>&lt;<span style=\"color: #267F99;\">TReturn<\/span>&gt; {\r\n    done<span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">true<\/span>;\r\n    value<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">TReturn<\/span>;\r\n}<\/pre>\n<\/div>\n<p>In short, what this means is that you&#8217;ll be able to appropriately narrow down values from iterators when dealing with them directly.<\/p>\n<p>To correctly represent the types that can be passed in to a generator from calls to <code style=\"color: #a31515;\">next()<\/code>, TypeScript 3.6 also infers certain uses of <code style=\"color: #a31515;\">yield<\/code> within the body of a generator function.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #0000ff;\">function<\/span><span class=\"pl-k\">*<\/span> foo() {\r\n    <span style=\"color: #0000ff;\">let<\/span> x<span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">string<\/span> <span class=\"pl-k\">=<\/span> <span style=\"color: #0000ff;\">yield<\/span>;\r\n    <span class=\"pl-c1\">console<\/span>.<span class=\"pl-c1\">log<\/span>(<span class=\"pl-smi\">x<\/span>.<span class=\"pl-c1\">toUpperCase<\/span>());\r\n}\r\n\r\n<span style=\"color: #0000ff;\">let<\/span> x <span class=\"pl-k\">=<\/span> <span style=\"color: #267F99;\">foo<\/span>();\r\n<span class=\"pl-smi\">x<\/span>.<span style=\"color: #267F99;\">next<\/span>(); <span style=\"color: #148A14;\">\/\/ first call to 'next' is always ignored<\/span>\r\n<span class=\"pl-smi\">x<\/span>.<span style=\"color: #267F99;\">next<\/span>(<span style=\"color: #09885A;\">42<\/span>); <span style=\"color: #148A14;\">\/\/ error! 'number' is not assignable to 'string'<\/span><\/pre>\n<\/div>\n<p>If you&#8217;d prefer to be explicit, you can also enforce the type of values that can be returned, yielded, and evaluated from <code style=\"color: #a31515;\">yield<\/code> expressions using an explicit return type. Below, <code style=\"color: #a31515;\">next()<\/code> can only be called with <code style=\"color: #a31515;\">boolean<\/code>s, and depending on the value of <code style=\"color: #a31515;\">done<\/code>, <code style=\"color: #a31515;\">value<\/code> is either a <code style=\"color: #a31515;\">string<\/code> or a <code style=\"color: #a31515;\">number<\/code>.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #148A14;\">\/**<\/span>\r\n<span style=\"color: #148A14;\"> * - yields numbers<\/span>\r\n<span style=\"color: #148A14;\"> * - returns strings<\/span>\r\n<span style=\"color: #148A14;\"> * - can be passed in booleans<\/span>\r\n<span style=\"color: #148A14;\"> *\/<\/span>\r\n<span style=\"color: #0000ff;\">function<\/span><span class=\"pl-k\">*<\/span> counter()<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">Generator<\/span>&lt;<span style=\"color: #0000ff;\">number<\/span>, <span style=\"color: #0000ff;\">string<\/span>, <span style=\"color: #0000ff;\">boolean<\/span>&gt; {\r\n    <span style=\"color: #0000ff;\">let<\/span> i <span class=\"pl-k\">=<\/span> <span style=\"color: #09885A;\">0<\/span>;\r\n    <span style=\"color: #0000ff;\">while<\/span> (<span style=\"color: #0000ff;\">true<\/span>) {\r\n        <span style=\"color: #0000ff;\">if<\/span> (<span style=\"color: #0000ff;\">yield<\/span> <span class=\"pl-smi\">i<\/span><span class=\"pl-k\">++<\/span>) {\r\n            <span style=\"color: #0000ff;\">break<\/span>;\r\n        }\r\n    }\r\n    <span style=\"color: #0000ff;\">return<\/span> <span style=\"color: #a31515;\"><span class=\"pl-pds\">\"<\/span>done!<span class=\"pl-pds\">\"<\/span><\/span>;\r\n}\r\n\r\n<span style=\"color: #0000ff;\">var<\/span> iter <span class=\"pl-k\">=<\/span> <span style=\"color: #267F99;\">counter<\/span>();\r\n<span style=\"color: #0000ff;\">var<\/span> curr <span class=\"pl-k\">=<\/span> <span class=\"pl-smi\">iter<\/span>.<span style=\"color: #267F99;\">next<\/span>()\r\n<span style=\"color: #0000ff;\">while<\/span> (<span class=\"pl-k\">!<\/span><span class=\"pl-smi\">curr<\/span>.<span class=\"pl-smi\">done<\/span>) {\r\n    <span class=\"pl-c1\">console<\/span>.<span class=\"pl-c1\">log<\/span>(<span class=\"pl-smi\">curr<\/span>.<span class=\"pl-c1\">value<\/span>);\r\n    <span class=\"pl-smi\">curr<\/span> <span class=\"pl-k\">=<\/span> <span class=\"pl-smi\">iter<\/span>.<span style=\"color: #267F99;\">next<\/span>(<span class=\"pl-smi\">curr<\/span>.<span class=\"pl-c1\">value<\/span> <span class=\"pl-k\">===<\/span> <span style=\"color: #09885A;\">5<\/span>)\r\n}\r\n<span class=\"pl-c1\">console<\/span>.<span class=\"pl-c1\">log<\/span>(<span class=\"pl-smi\">curr<\/span>.<span class=\"pl-c1\">value<\/span>.<span class=\"pl-c1\">toUpperCase<\/span>());\r\n\r\n<span style=\"color: #148A14;\">\/\/ prints:<\/span>\r\n<span style=\"color: #148A14;\">\/\/<\/span>\r\n<span style=\"color: #148A14;\">\/\/ 0<\/span>\r\n<span style=\"color: #148A14;\">\/\/ 1<\/span>\r\n<span style=\"color: #148A14;\">\/\/ 2<\/span>\r\n<span style=\"color: #148A14;\">\/\/ 3<\/span>\r\n<span style=\"color: #148A14;\">\/\/ 4<\/span>\r\n<span style=\"color: #148A14;\">\/\/ 5<\/span>\r\n<span style=\"color: #148A14;\">\/\/ DONE!<\/span><\/pre>\n<\/div>\n<p>For more details on the change, <a href=\"https:\/\/github.com\/Microsoft\/TypeScript\/issues\/2983\">see the pull request here<\/a>.<\/p>\n<h2 id=more-accurate-array-spread>More Accurate Array Spread<\/h2>\n<p>In pre-ES2015 targets, the most faithful emit for constructs like <code style=\"color: #a31515;\">for<\/code>\/<code style=\"color: #a31515;\">of<\/code> loops and array spreads can be a bit heavy. For this reason, TypeScript uses a simpler emit by default that only supports array types, and supports iterating on other types using the <code style=\"color: #a31515;\">--downlevelIteration<\/code> flag. Under this flag, the emitted code is more accurate, but is much larger.<\/p>\n<p><code style=\"color: #a31515;\">--downlevelIteration<\/code> being off by default works well since, by-and-large, most users targeting ES5 only plan to use iterative constructs with arrays. However, our emit that only supported arrays still had some observable differences in some edge cases.<\/p>\n<p>For example, the following example<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\">[<span class=\"pl-k\">...<\/span><span class=\"pl-c1\">Array<\/span>(<span style=\"color: #09885A;\">5<\/span>)]<\/pre>\n<\/div>\n<p>is equivalent to the following array.<\/p>\n<div class=\"highlight highlight-source-js\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\">[<span style=\"color: #0000ff;\">undefined<\/span>, <span style=\"color: #0000ff;\">undefined<\/span>, <span style=\"color: #0000ff;\">undefined<\/span>, <span style=\"color: #0000ff;\">undefined<\/span>, <span style=\"color: #0000ff;\">undefined<\/span>]<\/pre>\n<\/div>\n<p>However, TypeScript would instead transform the original code into this code:<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span class=\"pl-c1\">Array<\/span>(<span style=\"color: #09885A;\">5<\/span>).<span class=\"pl-c1\">slice<\/span>();<\/pre>\n<\/div>\n<p>This is slightly different. <code style=\"color: #a31515;\">Array(5)<\/code> produces an array with a length of 5, but with no defined property slots!<\/p>\n<div class=\"highlight highlight-source-js\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #09885A;\">1<\/span> <span style=\"color: #0000ff;\">in<\/span> [<span style=\"color: #0000ff;\">undefined<\/span>, <span style=\"color: #0000ff;\">undefined<\/span>, <span style=\"color: #0000ff;\">undefined<\/span>] <span style=\"color: #148A14;\">\/\/ true<\/span>\r\n<span style=\"color: #09885A;\">1<\/span> <span style=\"color: #0000ff;\">in<\/span> <span class=\"pl-c1\">Array<\/span>(<span style=\"color: #09885A;\">3<\/span>) <span style=\"color: #148A14;\">\/\/ false<\/span><\/pre>\n<\/div>\n<p>And when TypeScript calls <code style=\"color: #a31515;\">slice()<\/code>, it <em>also<\/em> creates an array with indices that haven&#8217;t been set.<\/p>\n<p>This might seem a bit of an esoteric difference, but it turns out many users were running into this undesirable behavior. Instead of using <code style=\"color: #a31515;\">slice()<\/code> and built-ins, TypeScript 3.6 introduces a new <code style=\"color: #a31515;\">__spreadArrays<\/code> helper to accurately model what happens in ECMAScript 2015 in older targets outside of <code style=\"color: #a31515;\">--downlevelIteration<\/code>. <code style=\"color: #a31515;\">__spreadArrays<\/code> is also available in <a href=\"https:\/\/github.com\/Microsoft\/tslib\/\">tslib<\/a> (which is worth checking out if you&#8217;re looking for smaller bundle sizes).<\/p>\n<p>For more information, <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/31166\">see the relevant pull request<\/a>.<\/p>\n<h2 id=improved-ux-around-promises>Improved UX Around Promises<\/h2>\n<p><code style=\"color: #a31515;\">Promise<\/code>s are one of the most common ways to work with asynchronous data nowadays. Unfortunately, using a <code style=\"color: #a31515;\">Promise<\/code>-oriented API can often be confusing for users. TypeScript 3.6 introduces some improvements for when <code style=\"color: #a31515;\">Promise<\/code>s are mis-handled.<\/p>\n<p>For example, it&#8217;s often very common to forget to <code style=\"color: #a31515;\">.then()<\/code> or <code style=\"color: #a31515;\">await<\/code> the contents of a <code style=\"color: #a31515;\">Promise<\/code> before passing it to another function. TypeScript&#8217;s error messages are now specialized, and inform the user that perhaps they should consider using the <code style=\"color: #a31515;\">await<\/code> keyword.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #0000ff;\">interface<\/span> <span style=\"color: #267F99;\">User<\/span> {\r\n    name<span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">string<\/span>;\r\n    age<span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">number<\/span>;\r\n    location<span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">string<\/span>;\r\n}\r\n\r\n<span style=\"color: #0000ff;\">declare<\/span> <span style=\"color: #0000ff;\">function<\/span> getUserData()<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">Promise<\/span>&lt;<span style=\"color: #267F99;\">User<\/span>&gt;;\r\n<span style=\"color: #0000ff;\">declare<\/span> <span style=\"color: #0000ff;\">function<\/span> displayUser(<span class=\"pl-v\">user<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">User<\/span>)<span class=\"pl-k\">:<\/span> <span class=\"pl-c1\">void<\/span>;\r\n\r\n<span style=\"color: #0000ff;\">async<\/span> <span style=\"color: #0000ff;\">function<\/span> f() {\r\n    <span style=\"color: #267F99;\">displayUser<\/span>(<span style=\"color: #267F99;\">getUserData<\/span>());\r\n<span style=\"color: #148A14;\">\/\/              ~~~~~~~~~~~~~<\/span>\r\n<span style=\"color: #148A14;\">\/\/ Argument of type 'Promise&lt;User&gt;' is not assignable to parameter of type 'User'.<\/span>\r\n<span style=\"color: #148A14;\">\/\/   ...<\/span>\r\n<span style=\"color: #148A14;\">\/\/ Did you forget to use 'await'?<\/span>\r\n}<\/pre>\n<\/div>\n<p>It&#8217;s also common to try to access a method before <code style=\"color: #a31515;\">await<\/code>-ing or <code style=\"color: #a31515;\">.then()<\/code>-ing a <code style=\"color: #a31515;\">Promise<\/code>. This is another example, among many others, where we&#8217;re able to do better.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #0000ff;\">async<\/span> <span style=\"color: #0000ff;\">function<\/span> getCuteAnimals() {\r\n    <span style=\"color: #267F99;\">fetch<\/span>(<span style=\"color: #a31515;\"><span class=\"pl-pds\">\"<\/span>https:\/\/reddit.com\/r\/aww.json<span class=\"pl-pds\">\"<\/span><\/span>)\r\n        .<span style=\"color: #267F99;\">json<\/span>()\r\n    <span style=\"color: #148A14;\">\/\/   ~~~~<\/span>\r\n    <span style=\"color: #148A14;\">\/\/ Property 'json' does not exist on type 'Promise&lt;Response&gt;'.<\/span>\r\n    <span style=\"color: #148A14;\">\/\/<\/span>\r\n    <span style=\"color: #148A14;\">\/\/ Did you forget to use 'await'?<\/span>\r\n}<\/pre>\n<\/div>\n<p>The intent is that even if a user is not aware of <code style=\"color: #a31515;\">await<\/code>, at the very least, these messages provide some more context on where to go from here.<\/p>\n<p>In the same vein of discoverability and making your life easier &#8211; apart from better error messages on <code style=\"color: #a31515;\">Promise<\/code>s, we now also provide quick fixes in some cases as well.<\/p>\n<p><a href=\"https:\/\/user-images.githubusercontent.com\/3277153\/61071690-8ca53480-a3c6-11e9-9b08-4e6d9851c9db.gif\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/3277153\/61071690-8ca53480-a3c6-11e9-9b08-4e6d9851c9db.gif\" alt=\"Quick fixes being applied to add missing 'await' keywords.\" \/><\/a><\/p>\n<p>For more details, <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/30646\">see the originating issue<\/a>, as well as the pull requests that link back to it.<\/p>\n<h2 id=better-unicode-support-for-identifiers>Better Unicode Support for Identifiers<\/h2>\n<p>TypeScript 3.6 contains better support for Unicode characters in identifiers when emitting to ES2015 and later targets.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #0000ff;\">const<\/span> \ud835\udcf1\ud835\udcee\ud835\udcf5\ud835\udcf5\ud835\udcf8 <span class=\"pl-k\">=<\/span> <span style=\"color: #a31515;\"><span class=\"pl-pds\">\"<\/span>world<span class=\"pl-pds\">\"<\/span><\/span>; <span style=\"color: #148A14;\">\/\/ previously disallowed, now allowed in '--target es2015'<\/span><\/pre>\n<\/div>\n<h2 id=import-meta-support-in-systemjs><code style=\"color: #a31515; font-size: 29px;\">import.meta<\/code> Support in SystemJS<\/h2>\n<p>TypeScript 3.6 supports transforming <code style=\"color: #a31515;\">import.meta<\/code> to <code style=\"color: #a31515;\">context.meta<\/code> when your <code style=\"color: #a31515;\">module<\/code> target is set to <code style=\"color: #a31515;\">system<\/code>.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #148A14;\">\/\/ This module:<\/span>\r\n\r\n<span class=\"pl-c1\">console<\/span>.<span class=\"pl-c1\">log<\/span>(<span style=\"color: #0000ff;\">import<\/span>.<span class=\"pl-c1\">meta<\/span>.<span class=\"pl-smi\">url<\/span>)\r\n\r\n<span style=\"color: #148A14;\">\/\/ gets turned into the following:<\/span>\r\n\r\n<span class=\"pl-smi\">System<\/span>.<span style=\"color: #267F99;\">register<\/span>([], <span style=\"color: #0000ff;\">function<\/span> (<span class=\"pl-v\">exports<\/span>, <span class=\"pl-v\">context<\/span>) {\r\n  <span style=\"color: #0000ff;\">return<\/span> {\r\n    setters: [],\r\n    <span style=\"color: #267F99;\">execute<\/span>: <span style=\"color: #0000ff;\">function<\/span> () {\r\n      <span class=\"pl-c1\">console<\/span>.<span class=\"pl-c1\">log<\/span>(<span class=\"pl-smi\">context<\/span>.<span class=\"pl-smi\">meta<\/span>.<span class=\"pl-smi\">url<\/span>);\r\n    }\r\n  };\r\n});<\/pre>\n<\/div>\n<h2 id=get-and-set-accessors-allowed-in-ambient-contexts><code style=\"color: #a31515; font-size: 29px;\">get<\/code> and <code style=\"color: #a31515; font-size: 29px;\">set<\/code> Accessors Are Allowed in Ambient Contexts<\/h2>\n<p>In previous versions of TypeScript, the language didn&#8217;t allow <code style=\"color: #a31515;\">get<\/code> and <code style=\"color: #a31515;\">set<\/code> accessors in ambient contexts (like in <code style=\"color: #a31515;\">declare<\/code>-d classes, or in <code style=\"color: #a31515;\">.d.ts<\/code> files in general). The rationale was that accessors weren&#8217;t distinct from properties as far as writing and reading to these properties; however, <a href=\"https:\/\/github.com\/tc39\/proposal-class-fields\/issues\/248\">because ECMAScript&#8217;s class fields proposal may have differing behavior from in existing versions of TypeScript<\/a>, we realized we needed a way to communicate this different behavior to provide appropriate errors in subclasses.<\/p>\n<p>As a result, users can write getters and setters in ambient contexts in TypeScript 3.6.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #0000ff;\">declare<\/span> <span style=\"color: #0000ff;\">class<\/span> <span style=\"color: #267F99;\">Foo<\/span> {\r\n    <span style=\"color: #148A14;\">\/\/ Allowed in 3.6+.<\/span>\r\n    <span style=\"color: #0000ff;\">get<\/span> x()<span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">number<\/span>;\r\n    <span style=\"color: #0000ff;\">set<\/span> x(<span class=\"pl-v\">val<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">number<\/span>)<span class=\"pl-k\">:<\/span> <span class=\"pl-c1\">void<\/span>;\r\n}<\/pre>\n<\/div>\n<p>In TypeScript 3.7, the compiler itself will take advantage of this feature so that generated <code style=\"color: #a31515;\">.d.ts<\/code> files will also emit <code style=\"color: #a31515;\">get<\/code>\/<code style=\"color: #a31515;\">set<\/code> accessors.<\/p>\n<h2 id=ambient-classes-and-functions-can-merge>Ambient Classes and Functions Can Merge<\/h2>\n<p>In previous versions of TypeScript, it was an error to merge classes and functions under any circumstances. Now, ambient classes and functions (classes\/functions with the <code style=\"color: #a31515;\">declare<\/code> modifier, or in <code style=\"color: #a31515;\">.d.ts<\/code> files) can merge. This means that now you can write the following:<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #0000ff;\">export<\/span> <span style=\"color: #0000ff;\">declare<\/span> <span style=\"color: #0000ff;\">function<\/span> Point2D(<span class=\"pl-v\">x<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">number<\/span>, <span class=\"pl-v\">y<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">number<\/span>)<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">Point2D<\/span>;\r\n<span style=\"color: #0000ff;\">export<\/span> <span style=\"color: #0000ff;\">declare<\/span> <span style=\"color: #0000ff;\">class<\/span> <span style=\"color: #267F99;\">Point2D<\/span> {\r\n    x<span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">number<\/span>;\r\n    y<span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">number<\/span>;\r\n    <span style=\"color: #0000ff;\">constructor<\/span>(<span class=\"pl-v\">x<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">number<\/span>, <span class=\"pl-v\">y<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">number<\/span>);\r\n}<\/pre>\n<\/div>\n<p>instead of needing to use<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #0000ff;\">export<\/span> <span style=\"color: #0000ff;\">interface<\/span> <span style=\"color: #267F99;\">Point2D<\/span> {\r\n    x<span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">number<\/span>;\r\n    y<span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">number<\/span>;\r\n}\r\n<span style=\"color: #0000ff;\">export<\/span> <span style=\"color: #0000ff;\">declare<\/span> <span style=\"color: #0000ff;\">var<\/span> Point2D<span class=\"pl-k\">:<\/span> {\r\n    (<span class=\"pl-v\">x<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">number<\/span>, <span class=\"pl-v\">y<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">number<\/span>)<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">Point2D<\/span>;\r\n    <span style=\"color: #0000ff;\">new<\/span> (<span class=\"pl-v\">x<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">number<\/span>, <span class=\"pl-v\">y<\/span><span class=\"pl-k\">:<\/span> <span style=\"color: #0000ff;\">number<\/span>)<span class=\"pl-k\">:<\/span> <span style=\"color: #267F99;\">Point2D<\/span>;\r\n}<\/pre>\n<\/div>\n<p>One advantage of this is that the callable constructor pattern can be easily expressed while also allowing namespaces to merge with these declarations (since <code style=\"color: #a31515;\">var<\/code> declarations can&#8217;t merge with <code style=\"color: #a31515;\">namespace<\/code>s).<\/p>\n<p>In TypeScript 3.7, the compiler will take advantage of this feature so that <code style=\"color: #a31515;\">.d.ts<\/code> files generated from <code style=\"color: #a31515;\">.js<\/code> files can appropriately capture both the callability and constructability of a class-like function.<\/p>\n<p>For more details, <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/32584\">see the original PR on GitHub<\/a>.<\/p>\n<h2 id=apis-to-support-build-and-incremental>APIs to Support <code style=\"color: #a31515; font-size: 29px;\">--build<\/code> and <code style=\"color: #a31515;\">--incremental<\/code><\/h2>\n<p>TypeScript 3.0 introduced support for referencing other projects and building them incrementally using the <code style=\"color: #a31515;\">--build<\/code> flag. Additionally, TypeScript 3.4 introduced the <code style=\"color: #a31515;\">--incremental<\/code> flag for saving information about previous compilations to only rebuild certain files. These flags were incredibly useful for structuring projects more flexibly and speeding builds up. Unfortunately, using these flags didn&#8217;t work with 3rd party build tools like Gulp and Webpack. TypeScript 3.6 now exposes two sets of APIs to operate on project references and incremental program building.<\/p>\n<p>For creating <code style=\"color: #a31515;\">--incremental<\/code> builds, users can leverage the <code style=\"color: #a31515;\">createIncrementalProgram<\/code> and <code style=\"color: #a31515;\">createIncrementalCompilerHost<\/code> APIs. Users can also re-hydrate old program instances from <code style=\"color: #a31515;\">.tsbuildinfo<\/code> files generated by this API using the newly exposed <code style=\"color: #a31515;\">readBuilderProgram<\/code> function, which is only meant to be used as for creating new programs (i.e. you can&#8217;t modify the returned instance &#8211; it&#8217;s only meant to be used for the <code style=\"color: #a31515;\">oldProgram<\/code> parameter in other <code style=\"color: #a31515;\">create*Program<\/code> functions).<\/p>\n<p>For leveraging project references, a new <code style=\"color: #a31515;\">createSolutionBuilder<\/code> function has been exposed, which returns an instance of the new type <code style=\"color: #a31515;\">SolutionBuilder<\/code>.<\/p>\n<p>For more details on these APIs, you can <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/31432\">see the original pull request<\/a>.<\/p>\n<h2 id=new-typescript-playground>New TypeScript Playground<\/h2>\n<p>The TypeScript playground has received a much-needed refresh with handy new functionality! The new playground is largely a fork of <a href=\"https:\/\/github.com\/agentcooper\">Artem Tyurin<\/a>&#8216;s <a href=\"https:\/\/github.com\/agentcooper\/typescript-play\">TypeScript playground<\/a> which community members have been using more and more. We owe Artem a big thanks for helping out here!<\/p>\n<p>The new playground now supports many new options including:<\/p>\n<ul>\n<li>The <code style=\"color: #a31515;\">target<\/code> option (allowing users to switch out of <code style=\"color: #a31515;\">es5<\/code> to <code style=\"color: #a31515;\">es3<\/code>, <code style=\"color: #a31515;\">es2015<\/code>, <code style=\"color: #a31515;\">esnext<\/code>, etc.)<\/li>\n<li>All the strictness flags (including just <code style=\"color: #a31515;\">strict<\/code>)<\/li>\n<li>Support for plain JavaScript files (using <code style=\"color: #a31515;\">allowJS<\/code> and optionally <code style=\"color: #a31515;\">checkJs<\/code>)<\/li>\n<\/ul>\n<p>These options also persist when sharing links to playground samples, allowing users to more reliably share examples without having to tell the recipient &#8220;oh, don&#8217;t forget to turn on the <code style=\"color: #a31515;\">noImplicitAny<\/code> option!&#8221;.<\/p>\n<p>In the near future, we&#8217;re going to be refreshing the playground samples, adding JSX support, and polishing automatic type acquisition, meaning that you&#8217;ll be able to see the same experience on the playground as you&#8217;d get in your personal editor.<\/p>\n<p>As we improve the playground and the website, <a href=\"https:\/\/github.com\/microsoft\/TypeScript-Website\/\">we welcome feedback and pull requests on GitHub<\/a>!<\/p>\n<h2 id=semicolon-aware-code-edits>Semicolon-Aware Code Edits<\/h2>\n<p>Editors like Visual Studio and Visual Studio Code can automatically apply quick fixes, refactorings, and other transformations like automatically importing values from other modules. These transformations are powered by TypeScript, and older versions of TypeScript unconditionally added semicolons to the end of every statement; unfortunately, this disagreed with many users&#8217; style guidelines, and many users were displeased with the editor inserting semicolons.<\/p>\n<p>TypeScript is now smart enough to detect whether your file uses semicolons when applying these sorts of edits. If your file generally lacks semicolons, TypeScript won&#8217;t add one.<\/p>\n<p>For more details, <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/31801\">see the corresponding pull request<\/a>.<\/p>\n<h2 id=smarter-auto-imports>Smarter Auto-Imports<\/h2>\n<p>JavaScript has a lot of different module syntaxes or conventions: the one in the ECMAScript standard, the one Node already supports (CommonJS), AMD, System.js, and more! For the most part, TypeScript would default to auto-importing using ECMAScript module syntax, which was often inappropriate in certain TypeScript projects with different compiler settings, or in Node projects with plain JavaScript and <code style=\"color: #a31515;\">require<\/code> calls.<\/p>\n<p>TypeScript 3.6 is now a bit smarter about looking at your existing imports before deciding on how to auto-import other modules. You can <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/32684\">see more details in the original pull request here<\/a>.<\/p>\n<h2 id=breaking-changes>Breaking Changes<\/h2>\n<h3 id=class-members-named-constructor-are-now-constructors>Class Members Named <code style=\"color: #a31515; font-size: 26px;\">\"constructor\"<\/code> Are Now Constructors<\/h3>\n<p>As per the ECMAScript specification, class declarations with methods named <code style=\"color: #a31515;\">constructor<\/code> are now constructor functions, regardless of whether they are declared using identifier names, or string names.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #0000ff;\">class<\/span> <span style=\"color: #267F99;\">C<\/span> {\r\n    <span style=\"color: #a31515;\"><span class=\"pl-pds\">\"<\/span>constructor<span class=\"pl-pds\">\"<\/span><\/span>() {\r\n        <span class=\"pl-c1\">console<\/span>.<span class=\"pl-c1\">log<\/span>(<span style=\"color: #a31515;\"><span class=\"pl-pds\">\"<\/span>I am the constructor now.<span class=\"pl-pds\">\"<\/span><\/span>);\r\n    }\r\n}<\/pre>\n<\/div>\n<p>A notable exception, and the workaround to this break, is using a computed property whose name evaluates to <code style=\"color: #a31515;\">\"constructor\"<\/code>.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #0000ff;\">class<\/span> <span style=\"color: #267F99;\">D<\/span> {\r\n    [<span style=\"color: #a31515;\"><span class=\"pl-pds\">\"<\/span>constructor<span class=\"pl-pds\">\"<\/span><\/span>]() {\r\n        <span class=\"pl-c1\">console<\/span>.<span class=\"pl-c1\">log<\/span>(<span style=\"color: #a31515;\"><span class=\"pl-pds\">\"<\/span>I'm not a constructor - just a plain method!<span class=\"pl-pds\">\"<\/span><\/span>);\r\n    }\r\n}<\/pre>\n<\/div>\n<h3 id=dom-updates>DOM Updates<\/h3>\n<p>Many declarations have been removed or changed within <code style=\"color: #a31515;\">lib.dom.d.ts<\/code>. This includes (but isn&#8217;t limited to) the following:<\/p>\n<ul>\n<li>The global <code style=\"color: #a31515;\">window<\/code> is no longer defined as type <code style=\"color: #a31515;\">Window<\/code> &#8211; instead, it is defined as type <code style=\"color: #a31515;\">Window &amp; typeof globalThis<\/code>. In some cases, it may be better to refer to its type as <code style=\"color: #a31515;\">typeof window<\/code>.<\/li>\n<li><code style=\"color: #a31515;\">GlobalFetch<\/code> is gone. Instead, use <code style=\"color: #a31515;\">WindowOrWorkerGlobalScope<\/code><\/li>\n<li>Certain non-standard properties on <code style=\"color: #a31515;\">Navigator<\/code> are gone.<\/li>\n<li>The <code style=\"color: #a31515;\">experimental-webgl<\/code> context is gone. Instead, use <code style=\"color: #a31515;\">webgl<\/code> or <code style=\"color: #a31515;\">webgl2<\/code>.<\/li>\n<\/ul>\n<p>If you believe a change has been made in error, <a href=\"https:\/\/github.com\/Microsoft\/TSJS-lib-generator\/\">please file an issue<\/a>!<\/p>\n<h3 id=jsdoc-comments-no-longer-merge>JSDoc Comments No Longer Merge<\/h3>\n<p>In JavaScript files, TypeScript will only consult immediately preceding JSDoc comments to figure out declared types.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #148A14;\">\/**<\/span>\r\n<span style=\"color: #148A14;\"> * <span class=\"pl-k\">@param<\/span> <span class=\"pl-en\">{string}<\/span> <span class=\"pl-smi\">arg<\/span><\/span>\r\n<span style=\"color: #148A14;\"> *\/<\/span>\r\n<span style=\"color: #148A14;\">\/**<\/span>\r\n<span style=\"color: #148A14;\"> * oh, hi, were you trying to type something?<\/span>\r\n<span style=\"color: #148A14;\"> *\/<\/span>\r\n<span style=\"color: #0000ff;\">function<\/span> whoWritesFunctionsLikeThis(<span class=\"pl-v\">arg<\/span>) {\r\n    <span style=\"color: #148A14;\">\/\/ 'arg' has type 'any'<\/span>\r\n}<\/pre>\n<\/div>\n<h3 id=keywords-cannot-contain-escape-sequences>Keywords Cannot Contain Escape Sequences<\/h3>\n<p>Previously keywords were allowed to contain escape sequences. TypeScript 3.6 disallows them.<\/p>\n<div class=\"highlight highlight-source-ts\">\n<pre class=\"lang:default decode:true\" style=\"background-color: #f0f0f0;padding: 10px;border-radius: 10px;\"><span style=\"color: #0000ff;\">while<\/span> (<span style=\"color: #0000ff;\">true<\/span>) {\r\n    \\<span class=\"pl-smi\">u0063ontinue<\/span>;\r\n<span style=\"color: #148A14;\">\/\/  ~~~~~~~~~~~~~<\/span>\r\n<span style=\"color: #148A14;\">\/\/  error! Keywords cannot contain escape characters.<\/span>\r\n}<\/pre>\n<\/div>\n<h2 id=whats-next>What&#8217;s Next?<\/h2>\n<p>To get an idea of what the team will be working on, <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/33118\">check out the 6-month roadmap for July to December of this year<\/a>.<\/p>\n<p>As always, we hope that this release of TypeScript makes coding a better experience and makes you happier. If you have any suggestions or run into any problems, we&#8217;re always interested so <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/new\/choose\">feel free to open an issue on GitHub<\/a>.<\/p>\n<p>Happy Hacking!<\/p>\n<p>&#8211; Daniel Rosenwasser and the TypeScript Team<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today we&#8217;re happy to announce the availability of TypeScript 3.6! For those unfamiliar, TypeScript is a language that builds on JavaScript by adding optional static types. These types can be checked by the TypeScript compiler to catch common errors in your programs (like misspelling properties and calling functions the wrong way). Tools like the TypeScript [&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-2300","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-typescript"],"acf":[],"blog_post_summary":"<p>Today we&#8217;re happy to announce the availability of TypeScript 3.6! For those unfamiliar, TypeScript is a language that builds on JavaScript by adding optional static types. These types can be checked by the TypeScript compiler to catch common errors in your programs (like misspelling properties and calling functions the wrong way). Tools like the TypeScript [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts\/2300","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=2300"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts\/2300\/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=2300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/categories?post=2300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/tags?post=2300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}