{"componentChunkName":"component---src-templates-handbook-tsx","path":"/docs/handbook/release-notes/overview.html","result":{"data":{"allSitePage":{"nodes":[{"path":"/dev-404-page/"},{"path":"/docs/handbook/advanced-types.html"},{"path":"/docs/handbook/basic-types.html"},{"path":"/docs/handbook/classes.html"},{"path":"/docs/handbook/compiler-options-in-msbuild.html"},{"path":"/docs/handbook/compiler-options.html"},{"path":"/docs/handbook/configuring-watch.html"},{"path":"/docs/handbook/declaration-merging.html"},{"path":"/docs/handbook/decorators.html"},{"path":"/docs/handbook/enums.html"},{"path":"/docs/handbook/functions.html"},{"path":"/docs/handbook/generics.html"},{"path":"/docs/handbook/integrating-with-build-tools.html"},{"path":"/docs/handbook/interfaces.html"},{"path":"/docs/handbook/iterators-and-generators.html"},{"path":"/docs/handbook/jsdoc-supported-types.html"},{"path":"/docs/handbook/jsx.html"},{"path":"/docs/handbook/literal-types.html"},{"path":"/docs/handbook/mixins.html"},{"path":"/docs/handbook/module-resolution.html"},{"path":"/docs/handbook/modules.html"},{"path":"/docs/handbook/namespaces-and-modules.html"},{"path":"/docs/handbook/namespaces.html"},{"path":"/docs/handbook/nightly-builds.html"},{"path":"/docs/handbook/project-references.html"},{"path":"/docs/handbook/symbols.html"},{"path":"/docs/handbook/"},{"path":"/docs/handbook/triple-slash-directives.html"},{"path":"/docs/handbook/type-checking-javascript-files.html"},{"path":"/docs/handbook/type-compatibility.html"},{"path":"/docs/handbook/type-inference.html"},{"path":"/docs/handbook/unions-and-intersections.html"},{"path":"/docs/handbook/utility-types.html"},{"path":"/docs/handbook/variable-declarations.html"},{"path":"/docs/handbook/writing-declaration-files.html"},{"path":"/docs/handbook/declaration-files/by-example.html"},{"path":"/docs/handbook/declaration-files/consumption.html"},{"path":"/docs/handbook/declaration-files/deep-dive.html"},{"path":"/docs/handbook/declaration-files/do-s-and-don-ts.html"},{"path":"/docs/handbook/declaration-files/introduction.html"},{"path":"/docs/handbook/declaration-files/library-structures.html"},{"path":"/docs/handbook/declaration-files/publishing.html"},{"path":"/docs/handbook/declaration-files/templates.html"},{"path":"/docs/handbook/release-notes/typescript-1-1.html"},{"path":"/docs/handbook/release-notes/typescript-1-3.html"},{"path":"/docs/handbook/release-notes/typescript-1-4.html"},{"path":"/docs/handbook/release-notes/typescript-1-5.html"},{"path":"/docs/handbook/release-notes/typescript-1-6.html"},{"path":"/docs/handbook/release-notes/typescript-1-7.html"},{"path":"/docs/handbook/release-notes/typescript-1-8.html"},{"path":"/docs/handbook/release-notes/typescript-2-0.html"},{"path":"/docs/handbook/release-notes/typescript-2-2.html"},{"path":"/docs/handbook/release-notes/typescript-2-1.html"},{"path":"/docs/handbook/release-notes/typescript-2-3.html"},{"path":"/docs/handbook/release-notes/typescript-2-4.html"},{"path":"/docs/handbook/release-notes/typescript-2-5.html"},{"path":"/docs/handbook/release-notes/typescript-2-6.html"},{"path":"/docs/handbook/release-notes/typescript-2-7.html"},{"path":"/docs/handbook/release-notes/typescript-2-8.html"},{"path":"/docs/handbook/release-notes/typescript-2-9.html"},{"path":"/docs/handbook/release-notes/typescript-3-0.html"},{"path":"/docs/handbook/release-notes/typescript-3-1.html"},{"path":"/docs/handbook/release-notes/typescript-3-2.html"},{"path":"/docs/handbook/release-notes/typescript-3-3.html"},{"path":"/docs/handbook/release-notes/typescript-3-4.html"},{"path":"/docs/handbook/release-notes/typescript-3-5.html"},{"path":"/docs/handbook/release-notes/typescript-3-6.html"},{"path":"/docs/handbook/release-notes/typescript-3-7.html"},{"path":"/docs/handbook/release-notes/typescript-3-8.html"},{"path":"/docs/handbook/asp-net-core.html"},{"path":"/docs/handbook/angular.html"},{"path":"/docs/handbook/dom-manipulation.html"},{"path":"/docs/handbook/gulp.html"},{"path":"/docs/handbook/migrating-from-javascript.html"},{"path":"/docs/handbook/react-&-webpack.html"},{"path":"/docs/handbook/react.html"},{"path":"/docs/handbook/typescript-in-5-minutes-func.html"},{"path":"/docs/handbook/typescript-in-5-minutes.html"},{"path":"/docs/handbook/typescript-in-5-minutes-oop.html"},{"path":"/docs/handbook/typescript-from-scratch.html"},{"path":"/docs/handbook/typescript-tooling-in-5-minutes.html"},{"path":"/docs/handbook/tsconfig-json.html"},{"path":"/docs/handbook/declaration-files/templates/global-modifying-module-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/global-plugin-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/global-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/module-class-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/module-function-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/module-plugin-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/module-d-ts.html"},{"path":"/docs/handbook/release-notes/overview.html"},{"path":"/tsconfig"},{"path":"/en/tsconfig"},{"path":"/ja/tsconfig"},{"path":"/vo/tsconfig"},{"path":"/play"},{"path":"/en/play"},{"path":"/es/play"},{"path":"/vo/play"},{"path":"/zh/play"},{"path":"/ja/play"},{"path":"/play/3-7/fixits/big-number-literals.ts"},{"path":"/play/3-7/fixits/const-to-let.ts"},{"path":"/play/3-7/fixits/infer-from-usage-changes.ts"},{"path":"/play/3-7/syntax-and-messaging/flattened-error-reporting.ts"},{"path":"/play/3-7/syntax-and-messaging/nullish-coalescing.ts"},{"path":"/play/3-7/syntax-and-messaging/optional-chaining.ts"},{"path":"/play/3-7/types-and-code-flow/assertion-functions.ts"},{"path":"/play/3-7/types-and-code-flow/recursive-type-references.ts"},{"path":"/play/3-7/types-and-code-flow/uncalled-function-checks.ts"},{"path":"/play/3-8/breaking-changes/checking-unions-with-index-signatures.ts"},{"path":"/play/3-8/jsdoc-improvements/accessibility-modifiers.js"},{"path":"/play/3-8/syntax-and-messaging/export-modules-from.ts"},{"path":"/play/3-8/syntax-and-messaging/private-class-fields.ts"},{"path":"/play/javascript/external-apis/typescript-with-deno.ts"},{"path":"/play/javascript/external-apis/typescript-with-node.js"},{"path":"/play/javascript/external-apis/typescript-with-web.js"},{"path":"/play/javascript/external-apis/typescript-with-webgl.js"},{"path":"/play/javascript/functions-with-javascript/function-chaining.ts"},{"path":"/play/javascript/functions-with-javascript/generic-functions.ts"},{"path":"/play/javascript/functions-with-javascript/typing-functions.ts"},{"path":"/play/javascript/helping-with-javascript/errors.ts"},{"path":"/play/javascript/helping-with-javascript/quick-fixes.ts"},{"path":"/play/javascript/javascript-essentials/code-flow.ts"},{"path":"/play/javascript/javascript-essentials/functions.ts"},{"path":"/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/play/javascript/modern-javascript/async-await.ts"},{"path":"/play/javascript/modern-javascript/immutability.ts"},{"path":"/play/javascript/modern-javascript/import-export.ts"},{"path":"/play/javascript/modern-javascript/jsdoc-support.js"},{"path":"/play/javascript/working-with-classes/classes-101.ts"},{"path":"/play/javascript/working-with-classes/generic-classes.ts"},{"path":"/play/javascript/working-with-classes/mixins.ts"},{"path":"/play/javascript/working-with-classes/this.ts"},{"path":"/play/playground/config/javascript-playgrounds.js"},{"path":"/play/playground/config/new-compiler-defaults.ts"},{"path":"/play/playground/language/automatic-type-acquisition.ts"},{"path":"/play/playground/language/fixits.ts"},{"path":"/play/playground/tooling/mobile-support.ts"},{"path":"/play/playground/tooling/sharable-urls.ts"},{"path":"/play/playground/tooling/typescript-versions.ts"},{"path":"/play/typescript/language/soundness.ts"},{"path":"/play/typescript/language/structural-typing.ts"},{"path":"/play/typescript/language/type-guards.ts"},{"path":"/play/typescript/language/type-widening-and-narrowing.ts"},{"path":"/play/typescript/language-extensions/enums.ts"},{"path":"/play/typescript/language-extensions/nominal-typing.ts"},{"path":"/play/typescript/language-extensions/types-vs-interfaces.ts"},{"path":"/play/typescript/meta-types/conditional-types.ts"},{"path":"/play/typescript/meta-types/discriminate-types.ts"},{"path":"/play/typescript/meta-types/indexed-types.ts"},{"path":"/play/typescript/meta-types/mapped-types.ts"},{"path":"/play/typescript/primitives/any.ts"},{"path":"/play/typescript/primitives/literals.ts"},{"path":"/play/typescript/primitives/union-and-intersection-types.ts"},{"path":"/play/typescript/primitives/unknown-and-never.ts"},{"path":"/play/typescript/type-primitives/built-in-utility-types.ts"},{"path":"/play/typescript/type-primitives/nullable-types.ts"},{"path":"/play/typescript/type-primitives/tuples.ts"},{"path":"/es/play/javascript/external-apis/typescript-with-deno.ts"},{"path":"/es/play/javascript/external-apis/typescript-with-node.js"},{"path":"/es/play/javascript/external-apis/typescript-with-web.js"},{"path":"/es/play/javascript/functions-with-javascript/function-chaining.ts"},{"path":"/es/play/javascript/functions-with-javascript/generic-functions.ts"},{"path":"/es/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/es/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/es/play/typescript/type-primitives/built-in-utility-types.ts"},{"path":"/es/play/typescript/type-primitives/nullable-types.ts"},{"path":"/es/play/typescript/type-primitives/tuples.ts"},{"path":"/ja/play/typescript/language-extensions/enums.ts"},{"path":"/ja/play/typescript/language-extensions/nominal-typing.ts"},{"path":"/ja/play/typescript/language-extensions/types-vs-interfaces.ts"},{"path":"/ja/play/typescript/primitives/any.ts"},{"path":"/ja/play/typescript/primitives/literals.ts"},{"path":"/ja/play/typescript/primitives/union-and-intersection-types.ts"},{"path":"/ja/play/typescript/type-primitives/built-in-utility-types.ts"},{"path":"/vo/play/javascript/javascript-essentials/code-flow.ts"},{"path":"/vo/play/javascript/javascript-essentials/functions.ts"},{"path":"/vo/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/vo/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/zh/play/javascript/external-apis/typescript-with-deno.ts"},{"path":"/zh/play/javascript/external-apis/typescript-with-node.js"},{"path":"/zh/play/javascript/external-apis/typescript-with-web.js"},{"path":"/zh/play/javascript/external-apis/typescript-with-webgl.js"},{"path":"/zh/play/javascript/functions-with-javascript/function-chaining.ts"},{"path":"/zh/play/javascript/functions-with-javascript/generic-functions.ts"},{"path":"/zh/play/javascript/functions-with-javascript/typing-functions.ts"},{"path":"/zh/play/javascript/helping-with-javascript/errors.ts"},{"path":"/zh/play/javascript/helping-with-javascript/quick-fixes.ts"},{"path":"/zh/play/javascript/javascript-essentials/code-flow.ts"},{"path":"/zh/play/javascript/javascript-essentials/functions.ts"},{"path":"/zh/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/zh/play/javascript/modern-javascript/import-export.ts"},{"path":"/zh/play/javascript/modern-javascript/jsdoc-support.js"},{"path":"/zh/play/javascript/working-with-classes/classes-101.ts"},{"path":"/zh/play/javascript/working-with-classes/generic-classes.ts"},{"path":"/zh/play/javascript/working-with-classes/mixins.ts"},{"path":"/zh/play/javascript/working-with-classes/this.ts"},{"path":"/zh/play/playground/config/javascript-playgrounds.js"},{"path":"/zh/play/playground/config/new-compiler-defaults.ts"},{"path":"/zh/play/playground/language/automatic-type-acquisition.ts"},{"path":"/zh/play/playground/language/fixits.ts"},{"path":"/zh/play/playground/tooling/mobile-support.ts"},{"path":"/zh/play/playground/tooling/sharable-urls.ts"},{"path":"/zh/play/playground/tooling/typescript-versions.ts"},{"path":"/zh/play/typescript/language/soundness.ts"},{"path":"/zh/play/typescript/language/structural-typing.ts"},{"path":"/zh/play/typescript/language/type-guards.ts"},{"path":"/zh/play/typescript/language/type-widening-and-narrowing.ts"},{"path":"/zh/play/typescript/language-extensions/enums.ts"},{"path":"/zh/play/typescript/language-extensions/nominal-typing.ts"},{"path":"/zh/play/typescript/language-extensions/types-vs-interfaces.ts"},{"path":"/zh/play/typescript/meta-types/conditional-types.ts"},{"path":"/zh/play/typescript/meta-types/discriminate-types.ts"},{"path":"/zh/play/typescript/meta-types/indexed-types.ts"},{"path":"/zh/play/typescript/meta-types/mapped-types.ts"},{"path":"/zh/play/typescript/primitives/any.ts"},{"path":"/zh/play/typescript/primitives/literals.ts"},{"path":"/zh/play/typescript/primitives/union-and-intersection-types.ts"},{"path":"/zh/play/typescript/primitives/unknown-and-never.ts"},{"path":"/zh/play/typescript/type-primitives/built-in-utility-types.ts"},{"path":"/zh/play/typescript/type-primitives/nullable-types.ts"},{"path":"/zh/play/typescript/type-primitives/tuples.ts"},{"path":"/zh/play/javascript/modern-javascript/immutability.ts"},{"path":"/zh/play/javascript/modern-javascript/async-await.ts"},{"path":"/zh/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/community"},{"path":"/es/community"},{"path":"/ja/community"},{"path":"/vo/community"},{"path":"/zh/community"},{"path":"/download"},{"path":"/es/download"},{"path":"/ja/download"},{"path":"/vo/download"},{"path":"/zh/download"},{"path":"/empty"},{"path":"/es/empty"},{"path":"/ja/empty"},{"path":"/vo/empty"},{"path":"/zh/empty"},{"path":"/"},{"path":"/es/"},{"path":"/ja/"},{"path":"/vo/"},{"path":"/zh/"},{"path":"/tools"},{"path":"/es/tools"},{"path":"/ja/tools"},{"path":"/vo/tools"},{"path":"/zh/tools"},{"path":"/why-create-typescript"},{"path":"/es/why-create-typescript"},{"path":"/ja/why-create-typescript"},{"path":"/vo/why-create-typescript"},{"path":"/zh/why-create-typescript"},{"path":"/docs/home"},{"path":"/es/docs/home"},{"path":"/ja/docs/home"},{"path":"/vo/docs/home"},{"path":"/zh/docs/home"},{"path":"/dev/playground-plugins/"},{"path":"/dev/sandbox/"},{"path":"/dev/twoslash/"},{"path":"/dev/typescript-vfs/"}]},"markdownRemark":{"id":"12ca428a-4ab3-50c6-a3ea-9cf784af68a5","excerpt":"This overview page is a summary contains a shorter version of all the release notes for TypeScript. TypeScript 3.8 Type-Only Imports and Export This feature is…","html":"<p>This overview page is a summary contains a shorter version of all the release notes for TypeScript.</p>\n<h1 id=\"typescript-38\" style=\"position:relative;\"><a href=\"#typescript-38\" aria-label=\"typescript 38 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 3.8</h1>\n<h2 id=\"type-only-imports-and-export\" style=\"position:relative;\"><a href=\"#type-only-imports-and-export\" aria-label=\"type only imports and export permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Type-Only Imports and Export</h2>\n<p>This feature is something most users may never have to think about; however, if you’ve hit issues under <code>--isolatedModules</code>, TypeScript’s <code>transpileModule</code> API, or Babel, this feature might be relevant.</p>\n<p>TypeScript 3.8 adds a new syntax for type-only imports and exports.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> type { SomeThing } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./some-module.js\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> type { SomeThing };</span></code></div></pre>\n<p><code>import type</code> only imports declarations to be used for type annotations and declarations.\nIt <em>always</em> gets fully erased, so there’s no remnant of it at runtime.\nSimilarly, <code>export type</code> only provides an export that can be used for type contexts, and is also erased from TypeScript’s output.</p>\n<p>It’s important to note that classes have a value at runtime and a type at design-time, and the use is context-sensitive.\nWhen using <code>import type</code> to import a class, you can’t do things like extend from it.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> type { Component } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"react\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> ButtonProps {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// ...</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Button </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Component&lt;ButtonProps&gt; {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">//               ~~~~~~~~~</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// error! 'Component' only refers to a type, but is being used as a value here.</span>\n\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// ...</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>If you’ve used Flow before, the syntax is fairly similar.\nOne difference is that we’ve added a few restrictions to avoid code that might appear ambiguous.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Is only 'Foo' a type? Or every declaration in the import?</span>\n<span style=\"color: #008000\">// We just give an error because it's not clear.</span>\n\n<span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> type Foo, { Bar, Baz } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"some-module\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #008000\">//     ~~~~~~~~~~~~~~~~~~~~~~</span>\n<span style=\"color: #008000\">// error! A type-only import can specify a default import or named bindings, but not both.</span></code></div></pre>\n<p>In conjunction with <code>import type</code>, TypeScript 3.8 also adds a new compiler flag to control what happens with imports that won’t be utilized at runtime: <code>importsNotUsedAsValues</code>.\nThis flag takes 3 different values:</p>\n<ul>\n<li><code>remove</code>: this is today’s behavior of dropping these imports. It’s going to continue to be the default, and is a non-breaking change.</li>\n<li><code>preserve</code>: this <em>preserves</em> all imports whose values are never used. This can cause imports/side-effects to be preserved.</li>\n<li><code>error</code>: this preserves all imports (the same as the <code>preserve</code> option), but will error when a value import is only used as a type. This might be useful if you want to ensure no values are being accidentally imported, but still make side-effect imports explicit.</li>\n</ul>\n<p>For more information about the feature, you can <a href=\"https://github.com/microsoft/TypeScript/pull/35200\">take a look at the pull request</a>, and <a href=\"https://github.com/microsoft/TypeScript/pull/36092/\">relevant changes</a> around broadening where imports from an <code>import type</code> declaration can be used.</p>\n<h2 id=\"ecmascript-private-fields\" style=\"position:relative;\"><a href=\"#ecmascript-private-fields\" aria-label=\"ecmascript private fields permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>ECMAScript Private Fields</h2>\n<p>TypeScript 3.8 brings support for ECMAScript’s private fields, part of the <a href=\"https://github.com/tc39/proposal-class-fields/\">stage-3 class fields proposal</a>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Person {</span>\n<span style=\"color: #000000\">    #name: string</span>\n\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(name: string) {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.#name = name;</span>\n<span style=\"color: #000000\">    }</span>\n\n<span style=\"color: #000000\">    greet() {</span>\n<span style=\"color: #000000\">        console.log(</span><span style=\"color: #A31515\">`Hello, my name is </span><span style=\"color: #0000FF\">${this</span><span style=\"color: #A31515\">.#name</span><span style=\"color: #0000FF\">}</span><span style=\"color: #A31515\">!`</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> jeremy = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Person(</span><span style=\"color: #A31515\">\"Jeremy Bearimy\"</span><span style=\"color: #000000\">);</span>\n\n<span style=\"color: #000000\">jeremy.#name</span>\n<span style=\"color: #008000\">//     ~~~~~</span>\n<span style=\"color: #008000\">// Property '#name' is not accessible outside class 'Person'</span>\n<span style=\"color: #008000\">// because it has a private identifier.</span></code></div></pre>\n<p>Unlike regular properties (even ones declared with the <code>private</code> modifier), private fields have a few rules to keep in mind.\nSome of them are:</p>\n<ul>\n<li>Private fields start with a <code>#</code> character. Sometimes we call these <em>private names</em>.</li>\n<li>Every private field name is uniquely scoped to its containing class.</li>\n<li>TypeScript accessibility modifiers like <code>public</code> or <code>private</code> can’t be used on private fields.</li>\n<li>Private fields can’t be accessed or even detected outside of the containing class - even by JS users! Sometimes we call this <em>hard privacy</em>.</li>\n</ul>\n<p>Apart from “hard” privacy, another benefit of private fields is that uniqueness we just mentioned.\nFor example, regular property declarations are prone to being overwritten in subclasses.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  foo = </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #000000\">  cHelper() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.foo;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> D </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  foo = </span><span style=\"color: #09835A\">20</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #000000\">  dHelper() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.foo;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> instance = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> D();</span>\n<span style=\"color: #008000\">// 'this.foo' refers to the same property on each instance.</span>\n<span style=\"color: #000000\">console.log(instance.cHelper()); </span><span style=\"color: #008000\">// prints '20'</span>\n<span style=\"color: #000000\">console.log(instance.dHelper()); </span><span style=\"color: #008000\">// prints '20'</span></code></div></pre>\n<p>With private fields, you’ll never have to worry about this, since each field name is unique to the containing class.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">    #foo = </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #000000\">    cHelper() {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.#foo;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> D </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">    #foo = </span><span style=\"color: #09835A\">20</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #000000\">    dHelper() {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.#foo;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> instance = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> D();</span>\n<span style=\"color: #008000\">// 'this.#foo' refers to a different field within each class.</span>\n<span style=\"color: #000000\">console.log(instance.cHelper()); </span><span style=\"color: #008000\">// prints '10'</span>\n<span style=\"color: #000000\">console.log(instance.dHelper()); </span><span style=\"color: #008000\">// prints '20'</span></code></div></pre>\n<p>Another thing worth noting is that accessing a private field on any other type will result in a <code>TypeError</code>!</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Square {</span>\n<span style=\"color: #000000\">    #sideLength: number;</span>\n\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(sideLength: number) {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.#sideLength = sideLength;</span>\n<span style=\"color: #000000\">    }</span>\n\n<span style=\"color: #000000\">    equals(other: any) {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.#sideLength === other.#sideLength;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> a = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Square(</span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> b = { sideLength: </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\"> };</span>\n\n<span style=\"color: #008000\">// Boom!</span>\n<span style=\"color: #008000\">// TypeError: attempted to get private field on non-instance</span>\n<span style=\"color: #008000\">// This fails because 'b' is not an instance of 'Square'.</span>\n<span style=\"color: #000000\">console.log(a.equals(b));</span></code></div></pre>\n<p>Finally, for any plain <code>.js</code> file users, private fields <em>always</em> have to be declared before they’re assigned to.</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// No declaration for '#foo'</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// :(</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(foo: number) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// SyntaxError!</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// '#foo' needs to be declared before writing to it.</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.#foo = foo;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>JavaScript has always allowed users to access undeclared properties, whereas TypeScript has always required declarations for class properties.\nWith private fields, declarations are always needed regardless of whether we’re working in <code>.js</code> or <code>.ts</code> files.</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">/** </span><span style=\"color: #0000FF\">@type</span><span style=\"color: #008000\"> {number} */</span>\n<span style=\"color: #000000\">  #foo;</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(foo: number) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// This works.</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.#foo = foo;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>For more information about the implementation, you can <a href=\"https://github.com/Microsoft/TypeScript/pull/30829\">check out the original pull request</a></p>\n<h3 id=\"which-should-i-use\" style=\"position:relative;\"><a href=\"#which-should-i-use\" aria-label=\"which should i use permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Which should I use?</h3>\n<p>We’ve already received many questions on which type of privates you should use as a TypeScript user: most commonly, “should I use the <code>private</code> keyword, or ECMAScript’s hash/pound (<code>#</code>) private fields?”\nIt depends!</p>\n<p>When it comes to properties, TypeScript’s <code>private</code> modifiers are fully erased - that means that at runtime, it acts entirely like a normal property and there’s no way to tell that it was declared with a <code>private modifier. When using the</code>private` keyword, privacy is only enforced at compile-time/design-time, and for JavaScript consumers it’s entirely intent-based.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">private</span><span style=\"color: #000000\"> foo = </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// This is an error at compile time,</span>\n<span style=\"color: #008000\">// but when TypeScript outputs .js files,</span>\n<span style=\"color: #008000\">// it'll run fine and print '10'.</span>\n<span style=\"color: #000000\">console.log(</span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> C().foo); </span><span style=\"color: #008000\">// prints '10'</span>\n<span style=\"color: #008000\">//                  ~~~</span>\n<span style=\"color: #008000\">// error! Property 'foo' is private and only accessible within class 'C'.</span>\n\n<span style=\"color: #008000\">// TypeScript allows this at compile-time</span>\n<span style=\"color: #008000\">// as a \"work-around\" to avoid the error.</span>\n<span style=\"color: #000000\">console.log(</span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> C()[</span><span style=\"color: #A31515\">\"foo\"</span><span style=\"color: #000000\">]); </span><span style=\"color: #008000\">// prints '10'</span></code></div></pre>\n<p>The upside is that this sort of “soft privacy” can help your consumers temporarily work around not having access to some API, and also works in any runtime.</p>\n<p>On the other hand, ECMAScript’s <code>#</code> privates are completely inaccessible outside of the class.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">    #foo = </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #000000\">console.log(</span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> C().#foo); </span><span style=\"color: #008000\">// SyntaxError</span>\n<span style=\"color: #008000\">//                  ~~~~</span>\n<span style=\"color: #008000\">// TypeScript reports an error *and*</span>\n<span style=\"color: #008000\">// this won't work at runtime!</span>\n\n<span style=\"color: #000000\">console.log(</span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> C()[</span><span style=\"color: #A31515\">\"#foo\"</span><span style=\"color: #000000\">]); </span><span style=\"color: #008000\">// prints undefined</span>\n<span style=\"color: #008000\">//          ~~~~~~~~~~~~~~~</span>\n<span style=\"color: #008000\">// TypeScript reports an error under 'noImplicitAny',</span>\n<span style=\"color: #008000\">// and this prints 'undefined'.</span></code></div></pre>\n<p>This hard privacy is really useful for strictly ensuring that nobody can take use of any of your internals.\nIf you’re a library author, removing or renaming a private field should never cause a breaking change.</p>\n<p>As we mentioned, another benefit is that subclassing can be easier with ECMAScript’s <code>#</code> privates because they <em>really</em> are private.\nWhen using ECMAScript <code>#</code> private fields, no subclass ever has to worry about collisions in field naming.\nWhen it comes to TypeScript’s <code>private</code> property declarations, users still have to be careful not to trample over properties declared in superclasses.</p>\n<p>One more thing to think about is where you intend for your code to run.\nTypeScript currently can’t support this feature unless targeting ECMAScript 2015 (ES6) targets or higher.\nThis is because our downleveled implementation uses <code>WeakMap</code>s to enforce privacy, and <code>WeakMap</code>s can’t be polyfilled in a way that doesn’t cause memory leaks.\nIn contrast, TypeScript’s <code>private</code>-declared properties work with all targets - even ECMAScript 3!</p>\n<p>A final consideration might be speed: <code>private</code> properties are no different from any other property, so accessing them is as fast as any other property access no matter which runtime you target.\nIn contrast, because <code>#</code> private fields are downleveled using <code>WeakMap</code>s, they may be slower to use.\nWhile some runtimes might optimize their actual implementations of <code>#</code> private fields, and even have speedy <code>WeakMap</code> implementations, that might not be the case in all runtimes.</p>\n<h2 id=\"export--as-ns-syntax\" style=\"position:relative;\"><a href=\"#export--as-ns-syntax\" aria-label=\"export  as ns syntax permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>export * as ns</code> Syntax</h2>\n<p>It’s often common to have a single entry-point that exposes all the members of another module as a single member.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">*</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> utilities </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./utilities.js\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> { utilities };</span></code></div></pre>\n<p>This is so common that ECMAScript 2020 recently added a new syntax to support this pattern!</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">*</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> utilities </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./utilities.js\"</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>This is a nice quality-of-life improvement to JavaScript, and TypeScript 3.8 implements this syntax.\nWhen your module target is earlier than <code>es2020</code>, TypeScript will output something along the lines of the first code snippet.</p>\n<h2 id=\"span-idtop-level-await--top-level-await\" style=\"position:relative;\"><a href=\"#span-idtop-level-await--top-level-await\" aria-label=\"span idtop level await  top level await permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><span id=\"top-level-await\" /> Top-Level <code>await</code></h2>\n<p>TypeScript 3.8 provides support for a handy upcoming ECMAScript feature called “top-level <code>await</code>“.</p>\n<p>JavaScript users often introduce an <code>async</code> function in order to use <code>await</code>, and then immediately called the function after defining it.</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> main() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> response = </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> fetch(</span><span style=\"color: #A31515\">\"...\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> greeting = </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> response.text();</span>\n<span style=\"color: #000000\">  console.log(greeting);</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #000000\">main().catch(e </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> console.error(e));</span></code></div></pre>\n<p>This is because previously in JavaScript (along with most other languages with a similar feature), <code>await</code> was only allowed within the body of an <code>async</code> function.\nHowever, with top-level <code>await</code>, we can use <code>await</code> at the top level of a module.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> response = </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> fetch(</span><span style=\"color: #A31515\">\"...\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> greeting = </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> response.text();</span>\n<span style=\"color: #000000\">console.log(greeting);</span>\n\n<span style=\"color: #008000\">// Make sure we're a module</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> {};</span></code></div></pre>\n<p>Note there’s a subtlety: top-level <code>await</code> only works at the top level of a <em>module</em>, and files are only considered modules when TypeScript finds an <code>import</code> or an <code>export</code>.\nIn some basic cases, you might need to write out <code>export {}</code> as some boilerplate to make sure of this.</p>\n<p>Top level <code>await</code> may not work in all environments where you might expect at this point.\nCurrently, you can only use top level <code>await</code> when the <code>target</code> compiler option is <code>es2017</code> or above, and <code>module</code> is <code>esnext</code> or <code>system</code>.\nSupport within several environments and bundlers may be limited or may require enabling experimental support.</p>\n<p>For more information on our implementation, you can <a href=\"https://github.com/microsoft/TypeScript/pull/35813\">check out the original pull request</a>.</p>\n<h2 id=\"es2020-for-target-and-module\" style=\"position:relative;\"><a href=\"#es2020-for-target-and-module\" aria-label=\"es2020 for target and module permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>es2020</code> for <code>target</code> and <code>module</code></h2>\n<p>TypeScript 3.8 supports <code>es2020</code> as an option for <code>module</code> and <code>target</code>.\nThis will preserve newer ECMAScript 2020 features like optional chaining, nullish coalescing, <code>export * as ns</code>, and dynamic <code>import(...)</code> syntax.\nIt also means <code>bigint</code> literals now have a stable <code>target</code> below <code>esnext</code>.</p>\n<h2 id=\"jsdoc-property-modifiers\" style=\"position:relative;\"><a href=\"#jsdoc-property-modifiers\" aria-label=\"jsdoc property modifiers permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>JSDoc Property Modifiers</h2>\n<p>TypeScript 3.8 supports JavaScript files by turning on the <code>allowJs</code> flag, and also supports <em>type-checking</em> those JavaScript files via the <code>checkJs</code> option or by adding a <code>// @ts-check</code> comment to the top of your <code>.js</code> files.</p>\n<p>Because JavaScript files don’t have dedicated syntax for type-checking, TypeScript leverages JSDoc.\nTypeScript 3.8 understands a few new JSDoc tags for properties.</p>\n<p>First are the accessibility modifiers: <code>@public</code>, <code>@private</code>, and <code>@protected</code>.\nThese tags work exactly like <code>public</code>, <code>private</code>, and <code>protected</code> respectively work in TypeScript.</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #008000\">// @ts-check</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Foo {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">/** </span><span style=\"color: #0000FF\">@private</span><span style=\"color: #008000\"> */</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.stuff = </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n\n<span style=\"color: #000000\">  printStuff() {</span>\n<span style=\"color: #000000\">    console.log(</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.stuff);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Foo().stuff;</span>\n<span style=\"color: #008000\">//        ~~~~~</span>\n<span style=\"color: #008000\">// error! Property 'stuff' is private and only accessible within class 'Foo'.</span></code></div></pre>\n<ul>\n<li><code>@public</code> is always implied and can be left off, but means that a property can be reached from anywhere.</li>\n<li><code>@private</code> means that a property can only be used within the containing class.</li>\n<li><code>@protected</code> means that a property can only be used within the containing class, and all derived subclasses, but not on dissimilar instances of the containing class.</li>\n</ul>\n<p>Next, we’ve also added the <code>@readonly</code> modifier to ensure that a property is only ever written to during initialization.</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #008000\">// @ts-check</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Foo {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">/** </span><span style=\"color: #0000FF\">@readonly</span><span style=\"color: #008000\"> */</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.stuff = </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n\n<span style=\"color: #000000\">  writeToStuff() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.stuff = </span><span style=\"color: #09835A\">200</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">//   ~~~~~</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// Cannot assign to 'stuff' because it is a read-only property.</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Foo().stuff++;</span>\n<span style=\"color: #008000\">//        ~~~~~</span>\n<span style=\"color: #008000\">// Cannot assign to 'stuff' because it is a read-only property.</span></code></div></pre>\n<h2 id=\"better-directory-watching-on-linux-and-watchoptions\" style=\"position:relative;\"><a href=\"#better-directory-watching-on-linux-and-watchoptions\" aria-label=\"better directory watching on linux and watchoptions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Better Directory Watching on Linux and <code>watchOptions</code></h2>\n<p>TypeScript 3.8 ships a new strategy for watching directories, which is crucial for efficiently picking up changes to <code>node_modules</code>.</p>\n<p>For some context, on operating systems like Linux, TypeScript installs directory watchers (as opposed to file watchers) on <code>node_modules</code> and many of its subdirectories to detect changes in dependencies.\nThis is because the number of available file watchers is often eclipsed by the of files in <code>node_modules</code>, whereas there are way fewer directories to track.</p>\n<p>Older versions of TypeScript would <em>immediately</em> install directory watchers on folders, and at startup that would be fine; however, during an npm install, a lot of activity will take place within <code>node_modules</code> and that can overwhelm TypeScript, often slowing editor sessions to a crawl.\nTo prevent this, TypeScript 3.8 waits slightly before installing directory watchers to give these highly volatile directories some time to stabilize.</p>\n<p>Because every project might work better under different strategies, and this new approach might not work well for your workflows, TypeScript 3.8 introduces a new <code>watchOptions</code> field in <code>tsconfig.json</code> and <code>jsconfig.json</code> which allows users to tell the compiler/language service which watching strategies should be used to keep track of files and directories.</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Some typical compiler options</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #CD3131\">compilerOptions</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #CD3131\">target</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"es2020\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #CD3131\">moduleResolution</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"node\"</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// ...</span>\n<span style=\"color: #000000\">  },</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// NEW: Options for file/directory watching</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #CD3131\">watchOptions</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// Use native file system events for files and directories</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #CD3131\">watchFile</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"useFsEvents\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #CD3131\">watchDirectory</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"useFsEvents\"</span><span style=\"color: #000000\">,</span>\n\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// Poll files for updates more frequently</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// when they're updated a lot.</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #CD3131\">fallbackPolling</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"dynamicPriority\"</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p><code>watchOptions</code> contains 4 new options that can be configured to handle how TypeScript keeps track of changes.</p>\n<p>For more information on these changes, <a href=\"https://github.com/microsoft/TypeScript/pull/35615\">head over to GitHub to see the pull request</a> to read more.</p>\n<h2 id=\"fast-and-loose-incremental-checking\" style=\"position:relative;\"><a href=\"#fast-and-loose-incremental-checking\" aria-label=\"fast and loose incremental checking permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>“Fast and Loose” Incremental Checking</h2>\n<p>TypeScript 3.8 introduces a new compiler option called <code>assumeChangesOnlyAffectDirectDependencies</code>.\nWhen this option is enabled, TypeScript will avoid rechecking/rebuilding all truly possibly-affected files, and only recheck/rebuild files that have changed as well as files that directly import them.</p>\n<p>In a codebase like Visual Studio Code, this reduced rebuild times for changes in certain files from about 14 seconds to about 1 second.\nWhile we don’t necessarily recommend this option for all codebases, you might be interested if you have an extremely large codebase and are willing to defer full project errors until later (e.g. a dedicated build via a <code>tsconfig.fullbuild.json</code> or in CI).</p>\n<p>For more details, you can <a href=\"https://github.com/microsoft/TypeScript/pull/35711\">see the original pull request</a>.</p>\n<h1 id=\"typescript-37\" style=\"position:relative;\"><a href=\"#typescript-37\" aria-label=\"typescript 37 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 3.7</h1>\n<h2 id=\"optional-chaining\" style=\"position:relative;\"><a href=\"#optional-chaining\" aria-label=\"optional chaining permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Optional Chaining</h2>\n<p><a href=\"/play/#example/optional-chaining\">Playground</a></p>\n<p>Optional chaining is <a href=\"https://github.com/microsoft/TypeScript/issues/16\">issue #16</a> on our issue tracker. For context, there have been over 23,000 issues on the TypeScript issue tracker since then.</p>\n<p>At its core, optional chaining lets us write code where TypeScript can immediately stop running some expressions if we run into a <code>null</code> or <code>undefined</code>.\nThe star of the show in optional chaining is the new <code>?.</code> operator for <em>optional property accesses</em>.\nWhen we write code like</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = foo?.bar.baz();</span></code></div></pre>\n<p>this is a way of saying that when <code>foo</code> is defined, <code>foo.bar.baz()</code> will be computed; but when <code>foo</code> is <code>null</code> or <code>undefined</code>, stop what we’re doing and just return <code>undefined</code>.”</p>\n<p>More plainly, that code snippet is the same as writing the following.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = foo === </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\"> || foo === </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\"> ? </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\"> : foo.bar.baz();</span></code></div></pre>\n<p>Note that if <code>bar</code> is <code>null</code> or <code>undefined</code>, our code will still hit an error accessing <code>baz</code>.\nLikewise, if <code>baz</code> is <code>null</code> or <code>undefined</code>, we’ll hit an error at the call site.\n<code>?.</code> only checks for whether the value on the <em>left</em> of it is <code>null</code> or <code>undefined</code> - not any of the subsequent properties.</p>\n<p>You might find yourself using <code>?.</code> to replace a lot of code that performs repetitive nullish checks using the <code>&#x26;&#x26;</code> operator.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Before</span>\n<span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (foo && foo.bar && foo.bar.baz) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// ...</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// After-ish</span>\n<span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (foo?.bar?.baz) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// ...</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Keep in mind that <code>?.</code> acts differently than those <code>&#x26;&#x26;</code> operations since <code>&#x26;&#x26;</code> will act specially on “falsy” values (e.g. the empty string, <code>0</code>, <code>NaN</code>, and, well, <code>false</code>), but this is an intentional feature of the construct.\nIt doesn’t short-circuit on valid data like <code>0</code> or empty strings.</p>\n<p>Optional chaining also includes two other operations.\nFirst there’s the <em>optional element access</em> which acts similarly to optional property accesses, but allows us to access non-identifier properties (e.g. arbitrary strings, numbers, and symbols):</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">/**</span>\n<span style=\"color: #008000\"> * Get the first element of the array if we have an array.</span>\n<span style=\"color: #008000\"> * Otherwise return undefined.</span>\n<span style=\"color: #008000\"> */</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> tryGetFirstElement&lt;T&gt;(arr?: T[]) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> arr?.[</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">];</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// equivalent to</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//   return (arr === null || arr === undefined) ?</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//       undefined :</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//       arr[0];</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>There’s also <em>optional call</em>, which allows us to conditionally call expressions if they’re not <code>null</code> or <code>undefined</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> makeRequest(url: string, log?: (msg: string) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void) {</span>\n<span style=\"color: #000000\">  log?.(</span><span style=\"color: #A31515\">`Request started at </span><span style=\"color: #0000FF\">${new</span><span style=\"color: #A31515\"> Date().toISOString()</span><span style=\"color: #0000FF\">}</span><span style=\"color: #A31515\">`</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// roughly equivalent to</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//   if (log != null) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//       log(`Request started at ${new Date().toISOString()}`);</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//   }</span>\n\n<span style=\"color: #000000\">  const result = (</span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> fetch(url)).json();</span>\n\n<span style=\"color: #000000\">  log?.(</span><span style=\"color: #A31515\">`Request finished at at </span><span style=\"color: #0000FF\">${new</span><span style=\"color: #A31515\"> Date().toISOString()</span><span style=\"color: #0000FF\">}</span><span style=\"color: #A31515\">`</span><span style=\"color: #000000\">);</span>\n\n<span style=\"color: #000000\">  return result;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>The “short-circuiting” behavior that optional chains have is limited property accesses, calls, element accesses - it doesn’t expand any further out from these expressions.\nIn other words,</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> result = foo?.bar / someComputation();</span></code></div></pre>\n<p>doesn’t stop the division or <code>someComputation()</code> call from occurring.\nIt’s equivalent to</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> temp = foo === </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\"> || foo === </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\"> ? </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\"> : foo.bar;</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> result = temp / someComputation();</span></code></div></pre>\n<p>That might result in dividing <code>undefined</code>, which is why in <code>strictNullChecks</code>, the following is an error.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> barPercentage(foo?: { bar: number }) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> foo?.bar / </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//     ~~~~~~~~</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Error: Object is possibly undefined.</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>More more details, you can <a href=\"https://github.com/tc39/proposal-optional-chaining/\">read up on the proposal</a> and <a href=\"https://github.com/microsoft/TypeScript/pull/33294\">view the original pull request</a>.</p>\n<h2 id=\"nullish-coalescing\" style=\"position:relative;\"><a href=\"#nullish-coalescing\" aria-label=\"nullish coalescing permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Nullish Coalescing</h2>\n<p><a href=\"/play/#example/nullish-coalescing\">Playground</a></p>\n<p>The <em>nullish coalescing operator</em> is another upcoming ECMAScript feature that goes hand-in-hand with optional chaining, and which our team has been involved with championing in TC39.</p>\n<p>You can think of this feature - the <code>??</code> operator - as a way to “fall back” to a default value when dealing with <code>null</code> or <code>undefined</code>.\nWhen we write code like</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = foo ?? bar();</span></code></div></pre>\n<p>this is a new way to say that the value <code>foo</code> will be used when it’s “present”;\nbut when it’s <code>null</code> or <code>undefined</code>, calculate <code>bar()</code> in its place.</p>\n<p>Again, the above code is equivalent to the following.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = foo !== </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\"> && foo !== </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\"> ? foo : bar();</span></code></div></pre>\n<p>The <code>??</code> operator can replace uses of <code>||</code> when trying to use a default value.\nFor example, the following code snippet tries to fetch the volume that was last saved in <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage\"><code>localStorage</code></a> (if it ever was);\nhowever, it has a bug because it uses <code>||</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> initializeAudio() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> volume = localStorage.volume || </span><span style=\"color: #09835A\">0.5</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// ...</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>When <code>localStorage.volume</code> is set to <code>0</code>, the page will set the volume to <code>0.5</code> which is unintended.\n<code>??</code> avoids some unintended behavior from <code>0</code>, <code>NaN</code> and <code>\"\"</code> being treated as falsy values.</p>\n<p>We owe a large thanks to community members <a href=\"https://github.com/Kingwl\">Wenlu Wang</a> and <a href=\"https://github.com/dragomirtitian\">Titian Cernicova Dragomir</a> for implementing this feature!\nFor more details, <a href=\"https://github.com/microsoft/TypeScript/pull/32883\">check out their pull request</a> and <a href=\"https://github.com/tc39/proposal-nullish-coalescing/\">the nullish coalescing proposal repository</a>.</p>\n<h2 id=\"assertion-functions\" style=\"position:relative;\"><a href=\"#assertion-functions\" aria-label=\"assertion functions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Assertion Functions</h2>\n<p><a href=\"/play/#example/assertion-functions\">Playground</a></p>\n<p>There’s a specific set of functions that <code>throw</code> an error if something unexpected happened.\nThey’re called “assertion” functions.\nAs an example, Node.js has a dedicated function for this called <code>assert</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #000000\">assert(someValue === </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">);</span></code></div></pre>\n<p>In this example if <code>someValue</code> isn’t equal to <code>42</code>, then <code>assert</code> will throw an <code>AssertionError</code>.</p>\n<p>Assertions in JavaScript are often used to guard against improper types being passed in.\nFor example,</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> multiply(x, y) {</span>\n<span style=\"color: #000000\">  assert(</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> x === </span><span style=\"color: #A31515\">\"number\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  assert(</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> y === </span><span style=\"color: #A31515\">\"number\"</span><span style=\"color: #000000\">);</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x * y;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Unfortunately in TypeScript these checks could never be properly encoded.\nFor loosely-typed code this meant TypeScript was checking less, and for slightly conservative code it often forced users to use type assertions.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> yell(str) {</span>\n<span style=\"color: #000000\">  assert(</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> str === </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">);</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> str.toUppercase();</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Oops! We misspelled 'toUpperCase'.</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Would be great if TypeScript still caught this!</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>The alternative was to instead rewrite the code so that the language could analyze it, but this isn’t convenient.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> yell(str) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> str !== </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">throw</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> TypeError(</span><span style=\"color: #A31515\">\"str should have been a string.\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Error caught!</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> str.toUppercase();</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Ultimately the goal of TypeScript is to type existing JavaScript constructs in the least disruptive way.\nFor that reason, TypeScript 3.7 introduces a new concept called “assertion signatures” which model these assertion functions.</p>\n<p>The first type of assertion signature models the way that Node’s <code>assert</code> function works.\nIt ensures that whatever condition is being checked must be true for the remainder of the containing scope.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> assert(condition: any, msg?: string): asserts condition {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (!condition) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">throw</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> AssertionError(msg);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p><code>asserts condition</code> says that whatever gets passed into the <code>condition</code> parameter must be true if the <code>assert</code> returns (because otherwise it would throw an error).\nThat means that for the rest of the scope, that condition must be truthy.\nAs an example, using this assertion function means we <em>do</em> catch our original <code>yell</code> example.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> yell(str) {</span>\n<span style=\"color: #000000\">  assert(</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> str === </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">);</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> str.toUppercase();</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//         ~~~~~~~~~~~</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// error: Property 'toUppercase' does not exist on type 'string'.</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//        Did you mean 'toUpperCase'?</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> assert(condition: any, msg?: string): asserts condition {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (!condition) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">throw</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> AssertionError(msg);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>The other type of assertion signature doesn’t check for a condition, but instead tells TypeScript that a specific variable or property has a different type.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> assertIsString(val: any): asserts val </span><span style=\"color: #0000FF\">is</span><span style=\"color: #000000\"> string {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> val !== </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">throw</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> AssertionError(</span><span style=\"color: #A31515\">\"Not a string!\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Here <code>asserts val is string</code> ensures that after any call to <code>assertIsString</code>, any variable passed in will be known to be a <code>string</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> yell(str: any) {</span>\n<span style=\"color: #000000\">  assertIsString(str);</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Now TypeScript knows that 'str' is a 'string'.</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> str.toUppercase();</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//         ~~~~~~~~~~~</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// error: Property 'toUppercase' does not exist on type 'string'.</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//        Did you mean 'toUpperCase'?</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>These assertion signatures are very similar to writing type predicate signatures:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> isString(val: any): val </span><span style=\"color: #0000FF\">is</span><span style=\"color: #000000\"> string {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> val === </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> yell(str: any) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (isString(str)) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> str.toUppercase();</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">throw</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"Oops!\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>And just like type predicate signatures, these assertion signatures are incredibly expressive.\nWe can express some fairly sophisticated ideas with these.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> assertIsDefined&lt;T&gt;(val: T): asserts val </span><span style=\"color: #0000FF\">is</span><span style=\"color: #000000\"> NonNullable&lt;T&gt; {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (val === </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\"> || val === </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">throw</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> AssertionError(</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #A31515\">`Expected 'val' to be defined, but received </span><span style=\"color: #0000FF\">${</span><span style=\"color: #A31515\">val</span><span style=\"color: #0000FF\">}</span><span style=\"color: #A31515\">`</span>\n<span style=\"color: #000000\">    );</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>To read up more about assertion signatures, <a href=\"https://github.com/microsoft/TypeScript/pull/32695\">check out the original pull request</a>.</p>\n<h2 id=\"better-support-for-never-returning-functions\" style=\"position:relative;\"><a href=\"#better-support-for-never-returning-functions\" aria-label=\"better support for never returning functions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Better Support for <code>never</code>-Returning Functions</h2>\n<p>As part of the work for assertion signatures, TypeScript needed to encode more about where and which functions were being called.\nThis gave us the opportunity to expand support for another class of functions: functions that return <code>never</code>.</p>\n<p>The intent of any function that returns <code>never</code> is that it never returns.\nIt indicates that an exception was thrown, a halting error condition occurred, or that the program exited.\nFor example, <a href=\"https://github.com/DefinitelyTyped/DefinitelyTyped/blob/5299d372a220584e75a031c13b3d555607af13f8/types/node/globals.d.ts#l874\"><code>process.exit(...)</code> in <code>@types/node</code></a> is specified to return <code>never</code>.</p>\n<p>In order to ensure that a function never potentially returned <code>undefined</code> or effectively returned from all code paths, TypeScript needed some syntactic signal - either a <code>return</code> or <code>throw</code> at the end of a function.\nSo users found themselves <code>return</code>-ing their failure functions.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> dispatch(x: string | number): SomeType {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> x === </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> doThingWithString(x);</span>\n<span style=\"color: #000000\">  } </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> x === </span><span style=\"color: #A31515\">\"number\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> doThingWithNumber(x);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> process.exit(</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Now when these <code>never</code>-returning functions are called, TypeScript recognizes that they affect the control flow graph and accounts for them.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> dispatch(x: string | number): SomeType {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> x === </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> doThingWithString(x);</span>\n<span style=\"color: #000000\">  } </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> x === </span><span style=\"color: #A31515\">\"number\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> doThingWithNumber(x);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  process.exit(</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>As with assertion functions, you can <a href=\"https://github.com/microsoft/TypeScript/pull/32695\">read up more at the same pull request</a>.</p>\n<h2 id=\"more-recursive-type-aliases\" style=\"position:relative;\"><a href=\"#more-recursive-type-aliases\" aria-label=\"more recursive type aliases permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>(More) Recursive Type Aliases</h2>\n<p><a href=\"/play/#example/recursive-type-references\">Playground</a></p>\n<p>Type aliases have always had a limitation in how they could be “recursively” referenced.\nThe reason is that any use of a type alias needs to be able to substitute itself with whatever it aliases.\nIn some cases, that’s not possible, so the compiler rejects certain recursive aliases like the following:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Foo = Foo;</span></code></div></pre>\n<p>This is a reasonable restriction because any use of <code>Foo</code> would need to be replaced with <code>Foo</code> which would need to be replaced with <code>Foo</code> which would need to be replaced with <code>Foo</code> which… well, hopefully you get the idea!\nIn the end, there isn’t a type that makes sense in place of <code>Foo</code>.</p>\n<p>This is fairly <a href=\"https://en.wikipedia.org/w/index.php?title=Recursive_data_type&#x26;oldid=913091335#in_type_synonyms\">consistent with how other languages treat type aliases</a>, but it does give rise to some slightly surprising scenarios for how users leverage the feature.\nFor example, in TypeScript 3.6 and prior, the following causes an error.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> ValueOrArray&lt;T&gt; = T | Array&lt;ValueOrArray&lt;T&gt;&gt;;</span>\n<span style=\"color: #008000\">//   ~~~~~~~~~~~~</span>\n<span style=\"color: #008000\">// error: Type alias 'ValueOrArray' circularly references itself.</span></code></div></pre>\n<p>This is strange because there is technically nothing wrong with any use users could always write what was effectively the same code by introducing an interface.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> ValueOrArray&lt;T&gt; = T | ArrayOfValueOrArray&lt;T&gt;;</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> ArrayOfValueOrArray&lt;T&gt; </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Array&lt;ValueOrArray&lt;T&gt;&gt; {}</span></code></div></pre>\n<p>Because interfaces (and other object types) introduce a level of indirection and their full structure doesn’t need to be eagerly built out, TypeScript has no problem working with this structure.</p>\n<p>But workaround of introducing the interface wasn’t intuitive for users.\nAnd in principle there really wasn’t anything wrong with the original version of <code>ValueOrArray</code> that used <code>Array</code> directly.\nIf the compiler was a little bit “lazier” and only calculated the type arguments to <code>Array</code> when necessary, then TypeScript could express these correctly.</p>\n<p>That’s exactly what TypeScript 3.7 introduces.\nAt the “top level” of a type alias, TypeScript will defer resolving type arguments to permit these patterns.</p>\n<p>This means that code like the following that was trying to represent JSON…</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Json = string | number | boolean | null | JsonObject | JsonArray;</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> JsonObject {</span>\n<span style=\"color: #000000\">  [property: string]: Json;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> JsonArray </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Array&lt;Json&gt; {}</span></code></div></pre>\n<p>can finally be rewritten without helper interfaces.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Json =</span>\n<span style=\"color: #000000\">  | string</span>\n<span style=\"color: #000000\">  | number</span>\n<span style=\"color: #000000\">  | boolean</span>\n<span style=\"color: #000000\">  | null</span>\n<span style=\"color: #000000\">  | { [property: string]: Json }</span>\n<span style=\"color: #000000\">  | Json[];</span></code></div></pre>\n<p>This new relaxation also lets us recursively reference type aliases in tuples as well.\nThe following code which used to error is now valid TypeScript code.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> VirtualNode = string | [string, { [key: string]: any }, ...VirtualNode[]];</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> myNode: VirtualNode = [</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #A31515\">\"div\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  { id: </span><span style=\"color: #A31515\">\"parent\"</span><span style=\"color: #000000\"> },</span>\n<span style=\"color: #000000\">  [</span><span style=\"color: #A31515\">\"div\"</span><span style=\"color: #000000\">, { id: </span><span style=\"color: #A31515\">\"first-child\"</span><span style=\"color: #000000\"> }, </span><span style=\"color: #A31515\">\"I'm the first child\"</span><span style=\"color: #000000\">],</span>\n<span style=\"color: #000000\">  [</span><span style=\"color: #A31515\">\"div\"</span><span style=\"color: #000000\">, { id: </span><span style=\"color: #A31515\">\"second-child\"</span><span style=\"color: #000000\"> }, </span><span style=\"color: #A31515\">\"I'm the second child\"</span><span style=\"color: #000000\">]</span>\n<span style=\"color: #000000\">];</span></code></div></pre>\n<p>For more information, you can <a href=\"https://github.com/microsoft/TypeScript/pull/33050\">read up on the original pull request</a>.</p>\n<h2 id=\"--declaration-and---allowjs\" style=\"position:relative;\"><a href=\"#--declaration-and---allowjs\" aria-label=\"  declaration and   allowjs permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>--declaration</code> and <code>--allowJs</code></h2>\n<p>The <code>--declaration</code> flag in TypeScript allows us to generate <code>.d.ts</code> files (declaration files) from TypeScript source files (i.e. <code>.ts</code> and <code>.tsx</code> files).\nThese <code>.d.ts</code> files are important for a couple of reasons.</p>\n<p>First of all, they’re important because they allow TypeScript to type-check against other projects without re-checking the original source code.\nThey’re also important because they allow TypeScript to interoperate with existing JavaScript libraries that weren’t built with TypeScript in mind.\nFinally, a benefit that is often underappreciated: both TypeScript <em>and</em> JavaScript users can benefit from these files when using editors powered by TypeScript to get things like better auto-completion.</p>\n<p>Unfortunately, <code>--declaration</code> didn’t work with the <code>--allowJs</code> flag which allows mixing TypeScript and JavaScript input files.\nThis was a frustrating limitation because it meant users couldn’t use the <code>--declaration</code> flag when migrating codebases, even if they were JSDoc-annotated.\nTypeScript 3.7 changes that, and allows the two options to be used together!</p>\n<p>The most impactful outcome of this feature might a bit subtle: with TypeScript 3.7, users can write libraries in JSDoc annotated JavaScript and support TypeScript users.</p>\n<p>The way that this works is that when using <code>allowJs</code>, TypeScript has some best-effort analyses to understand common JavaScript patterns; however, the way that some patterns are expressed in JavaScript don’t necessarily look like their equivalents in TypeScript.\nWhen <code>declaration</code> emit is turned on, TypeScript figures out the best way to transform JSDoc comments and CommonJS exports into valid type declarations and the like in the output <code>.d.ts</code> files.</p>\n<p>As an example, the following code snippet</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> assert = require(</span><span style=\"color: #A31515\">\"assert\"</span><span style=\"color: #000000\">);</span>\n\n<span style=\"color: #000000\">module.exports.blurImage = blurImage;</span>\n\n<span style=\"color: #008000\">/**</span>\n<span style=\"color: #008000\"> * Produces a blurred image from an input buffer.</span>\n<span style=\"color: #008000\"> *</span>\n<span style=\"color: #008000\"> * </span><span style=\"color: #0000FF\">@param</span><span style=\"color: #008000\"> input {Uint8Array}</span>\n<span style=\"color: #008000\"> * </span><span style=\"color: #0000FF\">@param</span><span style=\"color: #008000\"> width {number}</span>\n<span style=\"color: #008000\"> * </span><span style=\"color: #0000FF\">@param</span><span style=\"color: #008000\"> height {number}</span>\n<span style=\"color: #008000\"> */</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> blurImage(input, width, height) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> numPixels = width * height * </span><span style=\"color: #09835A\">4</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  assert(input.length === numPixels);</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> result = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Uint8Array(numPixels);</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// TODO</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> result;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Will produce a <code>.d.ts</code> file like</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">/**</span>\n<span style=\"color: #008000\"> * Produces a blurred image from an input buffer.</span>\n<span style=\"color: #008000\"> *</span>\n<span style=\"color: #008000\"> * </span><span style=\"color: #0000FF\">@param</span><span style=\"color: #008000\"> input {Uint8Array}</span>\n<span style=\"color: #008000\"> * </span><span style=\"color: #0000FF\">@param</span><span style=\"color: #008000\"> width {number}</span>\n<span style=\"color: #008000\"> * </span><span style=\"color: #0000FF\">@param</span><span style=\"color: #008000\"> height {number}</span>\n<span style=\"color: #008000\"> */</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> blurImage(</span>\n<span style=\"color: #000000\">  input: Uint8Array,</span>\n<span style=\"color: #000000\">  width: number,</span>\n<span style=\"color: #000000\">  height: number</span>\n<span style=\"color: #000000\">): Uint8Array;</span></code></div></pre>\n<p>This can go beyond basic functions with <code>@param</code> tags too, where the following example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #008000\">/**</span>\n<span style=\"color: #008000\"> * </span><span style=\"color: #0000FF\">@callback</span><span style=\"color: #008000\"> Job</span>\n<span style=\"color: #008000\"> * </span><span style=\"color: #0000FF\">@returns</span><span style=\"color: #008000\"> {void}</span>\n<span style=\"color: #008000\"> */</span>\n\n<span style=\"color: #008000\">/** Queues work */</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Worker {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(maxDepth = </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.started = </span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.depthLimit = maxDepth;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">/**</span>\n<span style=\"color: #008000\">     * NOTE: queued jobs may add more items to queue</span>\n<span style=\"color: #008000\">     * </span><span style=\"color: #0000FF\">@type</span><span style=\"color: #008000\"> {Job[]}</span>\n<span style=\"color: #008000\">     */</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.queue = [];</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">/**</span>\n<span style=\"color: #008000\">   * Adds a work item to the queue</span>\n<span style=\"color: #008000\">   * </span><span style=\"color: #0000FF\">@param</span><span style=\"color: #008000\"> {Job} work</span>\n<span style=\"color: #008000\">   */</span>\n<span style=\"color: #000000\">  push(work) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.queue.length + </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> &gt; </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.depthLimit) </span><span style=\"color: #0000FF\">throw</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Error(</span><span style=\"color: #A31515\">\"Queue full!\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.queue.push(work);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">/**</span>\n<span style=\"color: #008000\">   * Starts the queue if it has not yet started</span>\n<span style=\"color: #008000\">   */</span>\n<span style=\"color: #000000\">  start() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.started) </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.started = </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">while</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.queue.length) {</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #008000\">/** </span><span style=\"color: #0000FF\">@type</span><span style=\"color: #008000\"> {Job} */</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.queue.shift())();</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>will be transformed into the following <code>.d.ts</code> file:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">/**</span>\n<span style=\"color: #008000\"> * </span><span style=\"color: #0000FF\">@callback</span><span style=\"color: #008000\"> Job</span>\n<span style=\"color: #008000\"> * </span><span style=\"color: #0000FF\">@returns</span><span style=\"color: #008000\"> {void}</span>\n<span style=\"color: #008000\"> */</span>\n<span style=\"color: #008000\">/** Queues work */</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Worker {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(maxDepth?: number);</span>\n<span style=\"color: #000000\">  started: boolean;</span>\n<span style=\"color: #000000\">  depthLimit: number;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">/**</span>\n<span style=\"color: #008000\">   * NOTE: queued jobs may add more items to queue</span>\n<span style=\"color: #008000\">   * </span><span style=\"color: #0000FF\">@type</span><span style=\"color: #008000\"> {Job[]}</span>\n<span style=\"color: #008000\">   */</span>\n<span style=\"color: #000000\">  queue: Job[];</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">/**</span>\n<span style=\"color: #008000\">   * Adds a work item to the queue</span>\n<span style=\"color: #008000\">   * </span><span style=\"color: #0000FF\">@param</span><span style=\"color: #008000\"> {Job} work</span>\n<span style=\"color: #008000\">   */</span>\n<span style=\"color: #000000\">  push(work: Job): void;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">/**</span>\n<span style=\"color: #008000\">   * Starts the queue if it has not yet started</span>\n<span style=\"color: #008000\">   */</span>\n<span style=\"color: #000000\">  start(): boolean;</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Job = () </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void;</span></code></div></pre>\n<p>Note that when using these flags together, TypeScript doesn’t necessarily have to downlevel <code>.js</code> files.\nIf you simply want TypeScript to create <code>.d.ts</code> files, you can use the <code>--emitDeclarationOnly</code> compiler option.</p>\n<p>For more details, you can <a href=\"https://github.com/microsoft/TypeScript/pull/32372\">check out the original pull request</a>.</p>\n<h2 id=\"the-usedefineforclassfields-flag-and-the-declare-property-modifier\" style=\"position:relative;\"><a href=\"#the-usedefineforclassfields-flag-and-the-declare-property-modifier\" aria-label=\"the usedefineforclassfields flag and the declare property modifier permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The <code>useDefineForClassFields</code> Flag and The <code>declare</code> Property Modifier</h2>\n<p>Back when TypeScript implemented public class fields, we assumed to the best of our abilities that the following code</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  foo = </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  bar: string;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>would be equivalent to a similar assignment within a constructor body.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.foo = </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Unfortunately, while this seemed to be the direction that the proposal moved towards in its earlier days, there is an extremely strong chance that public class fields will be standardized differently.\nInstead, the original code sample might need to de-sugar to something closer to the following:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">    Object.defineProperty(</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"foo\"</span><span style=\"color: #000000\">, {</span>\n<span style=\"color: #000000\">      enumerable: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">      configurable: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">      writable: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">      value: </span><span style=\"color: #09835A\">100</span>\n<span style=\"color: #000000\">    });</span>\n<span style=\"color: #000000\">    Object.defineProperty(</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"bar\"</span><span style=\"color: #000000\">, {</span>\n<span style=\"color: #000000\">      enumerable: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">      configurable: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">      writable: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">      value: </span><span style=\"color: #0000FF\">void</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">0</span>\n<span style=\"color: #000000\">    });</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>While TypeScript 3.7 isn’t changing any existing emit by default, we’ve been rolling out changes incrementally to help users mitigate potential future breakage.\nWe’ve provided a new flag called <code>useDefineForClassFields</code> to enable this emit mode with some new checking logic.</p>\n<p>The two biggest changes are the following:</p>\n<ul>\n<li>Declarations are initialized with <code>Object.defineProperty</code>.</li>\n<li>Declarations are <em>always</em> initialized to <code>undefined</code>, even if they have no initializer.</li>\n</ul>\n<p>This can cause quite a bit of fallout for existing code that use inheritance. First of all, <code>set</code> accessors from base classes won’t get triggered - they’ll be completely overwritten.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Base {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">set</span><span style=\"color: #000000\"> data(value: string) {</span>\n<span style=\"color: #000000\">    console.log(</span><span style=\"color: #A31515\">\"data changed to \"</span><span style=\"color: #000000\"> + value);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Derived </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Base {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// No longer triggers a 'console.log'</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// when using 'useDefineForClassFields'.</span>\n<span style=\"color: #000000\">  data = </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Secondly, using class fields to specialize properties from base classes also won’t work.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Animal {</span>\n<span style=\"color: #000000\">  animalStuff: any;</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Dog </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Animal {</span>\n<span style=\"color: #000000\">  dogStuff: any;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> AnimalHouse {</span>\n<span style=\"color: #000000\">  resident: Animal;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(animal: Animal) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.resident = animal;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> DogHouse </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> AnimalHouse {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Initializes 'resident' to 'undefined'</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// after the call to 'super()' when</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// using 'useDefineForClassFields'!</span>\n<span style=\"color: #000000\">  resident: Dog;</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(dog: Dog) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">super</span><span style=\"color: #000000\">(dog);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>What these two boil down to is that mixing properties with accessors is going to cause issues, and so will re-declaring properties with no initializers.</p>\n<p>To detect the issue around accessors, TypeScript 3.7 will now emit <code>get</code>/<code>set</code> accessors in <code>.d.ts</code> files so that in TypeScript can check for overridden accessors.</p>\n<p>Code that’s impacted by the class fields change can get around the issue by converting field initializers to assignments in constructor bodies.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Base {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">set</span><span style=\"color: #000000\"> data(value: string) {</span>\n<span style=\"color: #000000\">    console.log(</span><span style=\"color: #A31515\">\"data changed to \"</span><span style=\"color: #000000\"> + value);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Derived </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Base {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">    data = </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>To help mitigate the second issue, you can either add an explicit initializer or add a <code>declare</code> modifier to indicate that a property should have no emit.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Animal {</span>\n<span style=\"color: #000000\">  animalStuff: any;</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Dog </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Animal {</span>\n<span style=\"color: #000000\">  dogStuff: any;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> AnimalHouse {</span>\n<span style=\"color: #000000\">  resident: Animal;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(animal: Animal) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.resident = animal;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> DogHouse </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> AnimalHouse {</span>\n<span style=\"color: #000000\">  declare resident: Dog;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//  ^^^^^^^</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// 'resident' now has a 'declare' modifier,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// and won't produce any output code.</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(dog: Dog) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">super</span><span style=\"color: #000000\">(dog);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Currently <code>useDefineForClassFields</code> is only available when targeting ES5 and upwards, since <code>Object.defineProperty</code> doesn’t exist in ES3.\nTo achieve similar checking for issues, you can create a seperate project that targets ES5 and uses <code>--noEmit</code> to avoid a full build.</p>\n<p>For more information, you can <a href=\"https://github.com/microsoft/TypeScript/pull/33509\">take a look at the original pull request for these changes</a>.</p>\n<p>We strongly encourage users to try the <code>useDefineForClassFields</code> flag and report back on our issue tracker or in the comments below.\nThis includes feedback on difficulty of adopting the flag so we can understand how we can make migration easier.</p>\n<h2 id=\"build-free-editing-with-project-references\" style=\"position:relative;\"><a href=\"#build-free-editing-with-project-references\" aria-label=\"build free editing with project references permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Build-Free Editing with Project References</h2>\n<p>TypeScript’s project references provide us with an easy way to break codebases up to give us faster compiles.\nUnfortunately, editing a project whose dependencies hadn’t been built (or whose output was out of date) meant that the editing experience wouldn’t work well.</p>\n<p>In TypeScript 3.7, when opening a project with dependencies, TypeScript will automatically use the source <code>.ts</code>/<code>.tsx</code> files instead.\nThis means projects using project references will now see an improved editing experience where semantic operations are up-to-date and “just work”.\nYou can disable this behavior with the compiler option <code>disableSourceOfProjectReferenceRedirect</code> which may be appropriate when working in very large projects where this change may impact editing performance.</p>\n<p>You can <a href=\"https://github.com/microsoft/TypeScript/pull/32028\">read up more about this change by reading up on its pull request</a>.</p>\n<h2 id=\"uncalled-function-checks\" style=\"position:relative;\"><a href=\"#uncalled-function-checks\" aria-label=\"uncalled function checks permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Uncalled Function Checks</h2>\n<p>A common and dangerous error is to forget to invoke a function, especially if the function has zero arguments or is named in a way that implies it might be a property rather than a function.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> User {</span>\n<span style=\"color: #000000\">  isAdministrator(): boolean;</span>\n<span style=\"color: #000000\">  notify(): void;</span>\n<span style=\"color: #000000\">  doNotDisturb?(): boolean;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// later...</span>\n\n<span style=\"color: #008000\">// Broken code, do not use!</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> doAdminThing(user: User) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// oops!</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (user.isAdministrator) {</span>\n<span style=\"color: #000000\">    sudo();</span>\n<span style=\"color: #000000\">    editTheConfiguration();</span>\n<span style=\"color: #000000\">  } </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">throw</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> AccessDeniedError(</span><span style=\"color: #A31515\">\"User is not an admin\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Here, we forgot to call <code>isAdministrator</code>, and the code incorrectly allows non-adminstrator users to edit the configuration!</p>\n<p>In TypeScript 3.7, this is identified as a likely error:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> doAdminThing(user: User) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (user.isAdministrator) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">//  ~~~~~~~~~~~~~~~~~~~~</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// error! This condition will always return true since the function is always defined.</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">//        Did you mean to call it instead?</span></code></div></pre>\n<p>This check is a breaking change, but for that reason the checks are very conservative.\nThis error is only issued in <code>if</code> conditions, and it is not issued on optional properties, if <code>strictNullChecks</code> is off, or if the function is later called within the body of the <code>if</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> User {</span>\n<span style=\"color: #000000\">  isAdministrator(): boolean;</span>\n<span style=\"color: #000000\">  notify(): void;</span>\n<span style=\"color: #000000\">  doNotDisturb?(): boolean;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> issueNotification(user: User) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (user.doNotDisturb) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// OK, property is optional</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (user.notify) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// OK, called the function</span>\n<span style=\"color: #000000\">    user.notify();</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>If you intended to test the function without calling it, you can correct the definition of it to include <code>undefined</code>/<code>null</code>, or use <code>!!</code> to write something like <code>if (!!user.isAdministrator)</code> to indicate that the coercion is intentional.</p>\n<p>We owe a big thanks to GitHub user <a href=\"https://github.com/jwbay\">@jwbay</a> who took the initiative to create a <a href=\"https://github.com/microsoft/TypeScript/pull/32802\">proof-of-concept</a> and iterated to provide us with with <a href=\"https://github.com/microsoft/TypeScript/pull/33178\">the current version</a>.</p>\n<h2 id=\"-ts-nocheck-in-typescript-files\" style=\"position:relative;\"><a href=\"#-ts-nocheck-in-typescript-files\" aria-label=\" ts nocheck in typescript files permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>// @ts-nocheck</code> in TypeScript Files</h2>\n<p>TypeScript 3.7 allows us to add <code>// @ts-nocheck</code> comments to the top of TypeScript files to disable semantic checks.\nHistorically this comment was only respected in JavaScript source files in the presence of <code>checkJs</code>, but we’ve expanded support to TypeScript files to make migrations easier for all users.</p>\n<h2 id=\"semicolon-formatter-option\" style=\"position:relative;\"><a href=\"#semicolon-formatter-option\" aria-label=\"semicolon formatter option permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Semicolon Formatter Option</h2>\n<p>TypeScript’s built-in formatter now supports semicolon insertion and removal at locations where a trailing semicolon is optional due to JavaScript’s automatic semicolon insertion (ASI) rules. The setting is available now in <a href=\"https://code.visualstudio.com/insiders/\">Visual Studio Code Insiders</a>, and will be available in Visual Studio 16.4 Preview 2 in the Tools Options menu.</p>\n<img width=\"833\" alt=\"New semicolon formatter option in VS Code\" src=\"https://user-images.githubusercontent.com/3277153/65913194-10066e80-e395-11e9-8a3a-4f7305c397d5.png\">\n<p>Choosing a value of “insert” or “remove” also affects the format of auto-imports, extracted types, and other generated code provided by TypeScript services. Leaving the setting on its default value of “ignore” makes generated code match the semicolon preference detected in the current file.</p>\n<h2 id=\"37-breaking-changes\" style=\"position:relative;\"><a href=\"#37-breaking-changes\" aria-label=\"37 breaking changes permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>3.7 Breaking Changes</h2>\n<h3 id=\"dom-changes\" style=\"position:relative;\"><a href=\"#dom-changes\" aria-label=\"dom changes permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>DOM Changes</h3>\n<p><a href=\"https://github.com/microsoft/TypeScript/pull/33627\">Types in <code>lib.dom.d.ts</code> have been updated</a>.\nThese changes are largely correctness changes related to nullability, but impact will ultimately depend on your codebase.</p>\n<h3 id=\"class-field-mitigations\" style=\"position:relative;\"><a href=\"#class-field-mitigations\" aria-label=\"class field mitigations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Class Field Mitigations</h3>\n<p><a href=\"#the-usedefineforclassfields-flag-and-the-declare-property-modifier\">As mentioned above</a>, TypeScript 3.7 emits <code>get</code>/<code>set</code> accessors in <code>.d.ts</code> files which can cause breaking changes for consumers on older versions of TypeScript like 3.5 and prior.\nTypeScript 3.6 users will not be impacted, since that version was future-proofed for this feature.</p>\n<p>While not a breakage per se, opting in to the <code>useDefineForClassFields</code> flag can cause breakage when:</p>\n<ul>\n<li>overriding an accessor in a derived class with a property declaration</li>\n<li>re-declaring a property declaration with no initializer</li>\n</ul>\n<p>To understand the full impact, read <a href=\"#the-usedefineforclassfields-flag-and-the-declare-property-modifier\">the section above on the <code>useDefineForClassFields</code> flag</a>.</p>\n<h3 id=\"function-truthy-checks\" style=\"position:relative;\"><a href=\"#function-truthy-checks\" aria-label=\"function truthy checks permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Function Truthy Checks</h3>\n<p>As mentioned above, TypeScript now errors when functions appear to be uncalled within <code>if</code> statement conditions.\nAn error is issued when a function type is checked in <code>if</code> conditions unless any of the following apply:</p>\n<ul>\n<li>the checked value comes from an optional property</li>\n<li><code>strictNullChecks</code> is disabled</li>\n<li>the function is later called within the body of the <code>if</code></li>\n</ul>\n<h3 id=\"local-and-imported-type-declarations-now-conflict\" style=\"position:relative;\"><a href=\"#local-and-imported-type-declarations-now-conflict\" aria-label=\"local and imported type declarations now conflict permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Local and Imported Type Declarations Now Conflict</h3>\n<p>Due to a bug, the following construct was previously allowed in TypeScript:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// ./someOtherModule.ts</span>\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> SomeType {</span>\n<span style=\"color: #000000\">  y: string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// ./myModule.ts</span>\n<span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> { SomeType } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./someOtherModule\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> SomeType {</span>\n<span style=\"color: #000000\">  x: number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> fn(arg: SomeType) {</span>\n<span style=\"color: #000000\">  console.log(arg.x); </span><span style=\"color: #008000\">// Error! 'x' doesn't exist on 'SomeType'</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Here, <code>SomeType</code> appears to originate in both the <code>import</code> declaration and the local <code>interface</code> declaration.\nPerhaps surprisingly, inside the module, <code>SomeType</code> refers exclusively to the <code>import</code>ed definition, and the local declaration <code>SomeType</code> is only usable when imported from another file.\nThis is very confusing and our review of the very small number of cases of code like this in the wild showed that developers usually thought something different was happening.</p>\n<p>In TypeScript 3.7, <a href=\"https://github.com/microsoft/TypeScript/pull/31231\">this is now correctly identified as a duplicate identifier error</a>.\nThe correct fix depends on the original intent of the author and should be addressed on a case-by-case basis.\nUsually, the naming conflict is unintentional and the best fix is to rename the imported type.\nIf the intent was to augment the imported type, a proper module augmentation should be written instead.</p>\n<h3 id=\"37-api-changes\" style=\"position:relative;\"><a href=\"#37-api-changes\" aria-label=\"37 api changes permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>3.7 API Changes</h3>\n<p>To enable the recursive type alias patterns described above, the <code>typeArguments</code> property has been removed from the <code>TypeReference</code> interface. Users should instead use the <code>getTypeArguments</code> function on <code>TypeChecker</code> instances.</p>\n<h2 id=\"typescript-36\" style=\"position:relative;\"><a href=\"#typescript-36\" aria-label=\"typescript 36 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 3.6</h2>\n<h2 id=\"stricter-generators\" style=\"position:relative;\"><a href=\"#stricter-generators\" aria-label=\"stricter generators permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Stricter Generators</h2>\n<p>TypeScript 3.6 introduces stricter checking for iterators and generator functions.\nIn earlier versions, users of generators had no way to differentiate whether a value was yielded or returned from a generator.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function*</span><span style=\"color: #000000\"> foo() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (Math.random() &lt; </span><span style=\"color: #09835A\">0.5</span><span style=\"color: #000000\">) </span><span style=\"color: #0000FF\">yield</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"Finished!\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> iter = foo();</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> curr = iter.next();</span>\n<span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (curr.done) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// TypeScript 3.5 and prior thought this was a 'string | number'.</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// It should know it's 'string' since 'done' was 'true'!</span>\n<span style=\"color: #000000\">  curr.value;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Additionally, generators just assumed the type of <code>yield</code> was always <code>any</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function*</span><span style=\"color: #000000\"> bar() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: { hello(): void } = yield;</span>\n<span style=\"color: #000000\">  x.hello();</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> iter = bar();</span>\n<span style=\"color: #000000\">iter.next();</span>\n<span style=\"color: #000000\">iter.next(</span><span style=\"color: #09835A\">123</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// oops! runtime error!</span></code></div></pre>\n<p>In TypeScript 3.6, the checker now knows that the correct type for <code>curr.value</code> should be <code>string</code> in our first example, and will correctly error on our call to <code>next()</code> in our last example.\nThis is thanks to some changes in the <code>Iterator</code> and <code>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>Generator</code> type.</p>\n<p>The <code>Iterator</code> type now allows users to specify the yielded type, the returned type, and the type that <code>next</code> can accept.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Iterator&lt;T, TReturn = any, TNext = undefined&gt; {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Takes either 0 or 1 arguments - doesn't accept 'undefined'</span>\n<span style=\"color: #000000\">  next(...args: [] | [TNext]): IteratorResult&lt;T, TReturn&gt;;</span>\n<span style=\"color: #000000\">  return?(value?: TReturn): IteratorResult&lt;T, TReturn&gt;;</span>\n<span style=\"color: #000000\">  throw?(e?: any): IteratorResult&lt;T, TReturn&gt;;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Building on that work, the new <code>Generator</code> type is an <code>Iterator</code> that always has both the <code>return</code> and <code>throw</code> methods present, and is also iterable.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Generator&lt;T = unknown, TReturn = any, TNext = unknown&gt;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Iterator&lt;T, TReturn, TNext&gt; {</span>\n<span style=\"color: #000000\">  next(...args: [] | [TNext]): IteratorResult&lt;T, TReturn&gt;;</span>\n<span style=\"color: #000000\">  return(value: TReturn): IteratorResult&lt;T, TReturn&gt;;</span>\n<span style=\"color: #000000\">  throw(e: any): IteratorResult&lt;T, TReturn&gt;;</span>\n<span style=\"color: #000000\">  [Symbol.iterator](): Generator&lt;T, TReturn, TNext&gt;;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>To allow differentiation between returned values and yielded values, TypeScript 3.6 converts the <code>IteratorResult</code> type to a discriminated union type:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> IteratorResult&lt;T, TReturn = any&gt; =</span>\n<span style=\"color: #000000\">  | IteratorYieldResult&lt;T&gt;</span>\n<span style=\"color: #000000\">  | IteratorReturnResult&lt;TReturn&gt;;</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> IteratorYieldResult&lt;TYield&gt; {</span>\n<span style=\"color: #000000\">  done?: false;</span>\n<span style=\"color: #000000\">  value: TYield;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> IteratorReturnResult&lt;TReturn&gt; {</span>\n<span style=\"color: #000000\">  done: true;</span>\n<span style=\"color: #000000\">  value: TReturn;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>In short, what this means is that you’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>next()</code>, TypeScript 3.6 also infers certain uses of <code>yield</code> within the body of a generator function.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function*</span><span style=\"color: #000000\"> foo() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: string = yield;</span>\n<span style=\"color: #000000\">  console.log(x.toUpperCase());</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = foo();</span>\n<span style=\"color: #000000\">x.next(); </span><span style=\"color: #008000\">// first call to 'next' is always ignored</span>\n<span style=\"color: #000000\">x.next(</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// error! 'number' is not assignable to 'string'</span></code></div></pre>\n<p>If you’d prefer to be explicit, you can also enforce the type of values that can be returned, yielded, and evaluated from <code>yield</code> expressions using an explicit return type.\nBelow, <code>next()</code> can only be called with <code>boolean</code>s, and depending on the value of <code>done</code>, <code>value</code> is either a <code>string</code> or a <code>number</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">/**</span>\n<span style=\"color: #008000\"> * - yields numbers</span>\n<span style=\"color: #008000\"> * - returns strings</span>\n<span style=\"color: #008000\"> * - can be passed in booleans</span>\n<span style=\"color: #008000\"> */</span>\n<span style=\"color: #0000FF\">function*</span><span style=\"color: #000000\"> counter(): Generator&lt;number, string, boolean&gt; {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> i = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">while</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (yield i++) {</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0000FF\">break</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"done!\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> iter = counter();</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> curr = iter.next();</span>\n<span style=\"color: #0000FF\">while</span><span style=\"color: #000000\"> (!curr.done) {</span>\n<span style=\"color: #000000\">  console.log(curr.value);</span>\n<span style=\"color: #000000\">  curr = iter.next(curr.value === </span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #000000\">console.log(curr.value.toUpperCase());</span>\n\n<span style=\"color: #008000\">// prints:</span>\n<span style=\"color: #008000\">//</span>\n<span style=\"color: #008000\">// 0</span>\n<span style=\"color: #008000\">// 1</span>\n<span style=\"color: #008000\">// 2</span>\n<span style=\"color: #008000\">// 3</span>\n<span style=\"color: #008000\">// 4</span>\n<span style=\"color: #008000\">// 5</span>\n<span style=\"color: #008000\">// DONE!</span></code></div></pre>\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\" style=\"position:relative;\"><a href=\"#more-accurate-array-spread\" aria-label=\"more accurate array spread permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>More Accurate Array Spread</h2>\n<p>In pre-ES2015 targets, the most faithful emit for constructs like <code>for</code>/<code>of</code> loops and array spreads can be a bit heavy.\nFor this reason, TypeScript uses a simpler emit by default that only supports array types, and supports iterating on other types using the <code>--downlevelIteration</code> flag.\nThe looser default without <code>--downlevelIteration</code> works fairly well; however, there were some common cases where the transformation of array spreads had observable differences.\nFor example, the following array containing a spread</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #000000\">[...Array(</span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">)];</span></code></div></pre>\n<p>can be rewritten as the following array literal</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #000000\">[</span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">];</span></code></div></pre>\n<p>However, TypeScript would instead transform the original code into this code:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #000000\">Array(</span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">).slice();</span></code></div></pre>\n<p>which is slightly different.\n<code>Array(5)</code> produces an array with a length of 5, but with no defined property slots.</p>\n<p>TypeScript 3.6 introduces a new <code>__spreadArrays</code> helper to accurately model what happens in ECMAScript 2015 in older targets outside of <code>--downlevelIteration</code>.\n<code>__spreadArrays</code> is also available in <a href=\"https://github.com/Microsoft/tslib/\">tslib</a>.</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\" style=\"position:relative;\"><a href=\"#improved-ux-around-promises\" aria-label=\"improved ux around promises permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Improved UX Around Promises</h2>\n<p>TypeScript 3.6 introduces some improvements for when <code>Promise</code>s are mis-handled.</p>\n<p>For example, it’s often very common to forget to <code>.then()</code> or <code>await</code> the contents of a <code>Promise</code> before passing it to another function.\nTypeScript’s error messages are now specialized, and inform the user that perhaps they should consider using the <code>await</code> keyword.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> User {</span>\n<span style=\"color: #000000\">  name: string;</span>\n<span style=\"color: #000000\">  age: number;</span>\n<span style=\"color: #000000\">  location: string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> getUserData(): Promise&lt;User&gt;;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> displayUser(user: User): void;</span>\n\n<span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f() {</span>\n<span style=\"color: #000000\">  displayUser(getUserData());</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//              ~~~~~~~~~~~~~</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Argument of type 'Promise&lt;User&gt;' is not assignable to parameter of type 'User'.</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//   ...</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Did you forget to use 'await'?</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>It’s also common to try to access a method before <code>await</code>-ing or <code>.then()</code>-ing a <code>Promise</code>.\nThis is another example, among many others, where we’re able to do better.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> getCuteAnimals() {</span>\n<span style=\"color: #000000\">  fetch(</span><span style=\"color: #A31515\">\"https://reddit.com/r/aww.json\"</span><span style=\"color: #000000\">).json();</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//   ~~~~</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Property 'json' does not exist on type 'Promise&lt;Response&gt;'.</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Did you forget to use 'await'?</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\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\" style=\"position:relative;\"><a href=\"#better-unicode-support-for-identifiers\" aria-label=\"better unicode support for identifiers permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>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<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> 𝓱𝓮𝓵𝓵𝓸 = </span><span style=\"color: #A31515\">\"world\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// previously disallowed, now allowed in '--target es2015'</span></code></div></pre>\n<h2 id=\"importmeta-support-in-systemjs\" style=\"position:relative;\"><a href=\"#importmeta-support-in-systemjs\" aria-label=\"importmeta support in systemjs permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>import.meta</code> Support in SystemJS</h2>\n<p>TypeScript 3.6 supports transforming <code>import.meta</code> to <code>context.meta</code> when your <code>module</code> target is set to <code>system</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// This module:</span>\n\n<span style=\"color: #000000\">console.log(import.meta.url);</span>\n\n<span style=\"color: #008000\">// gets turned into the following:</span>\n\n<span style=\"color: #000000\">System.register([], </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(exports, context) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    setters: [],</span>\n<span style=\"color: #000000\">    execute: </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">      console.log(context.meta.url);</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">  };</span>\n<span style=\"color: #000000\">});</span></code></div></pre>\n<h2 id=\"get-and-set-accessors-are-allowed-in-ambient-contexts\" style=\"position:relative;\"><a href=\"#get-and-set-accessors-are-allowed-in-ambient-contexts\" aria-label=\"get and set accessors are allowed in ambient contexts permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>get</code> and <code>set</code> Accessors Are Allowed in Ambient Contexts</h2>\n<p>In previous versions of TypeScript, the language didn’t allow <code>get</code> and <code>set</code> accessors in ambient contexts (like in <code>declare</code>-d classes, or in <code>.d.ts</code> files in general).\nThe rationale was that accessors weren’t distinct from properties as far as writing and reading to these properties;\nhowever, <a href=\"https://github.com/tc39/proposal-class-fields/issues/248\">because ECMAScript’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<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Foo {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Allowed in 3.6+.</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">get</span><span style=\"color: #000000\"> x(): number;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">set</span><span style=\"color: #000000\"> x(val: number): void;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>In TypeScript 3.7, the compiler itself will take advantage of this feature so that generated <code>.d.ts</code> files will also emit <code>get</code>/<code>set</code> accessors.</p>\n<h2 id=\"ambient-classes-and-functions-can-merge\" style=\"position:relative;\"><a href=\"#ambient-classes-and-functions-can-merge\" aria-label=\"ambient classes and functions can merge permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>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.\nNow, ambient classes and functions (classes/functions with the <code>declare</code> modifier, or in <code>.d.ts</code> files) can merge.\nThis means that now you can write the following:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> Point2D(x: number, y: number): Point2D;</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Point2D {</span>\n<span style=\"color: #000000\">  x: number;</span>\n<span style=\"color: #000000\">  y: number;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(x: number, y: number);</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>instead of needing to use</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Point2D {</span>\n<span style=\"color: #000000\">  x: number;</span>\n<span style=\"color: #000000\">  y: number;</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> Point2D: {</span>\n<span style=\"color: #000000\">  (x: number, y: number): Point2D;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> (x: number, y: number): Point2D;</span>\n<span style=\"color: #000000\">};</span></code></div></pre>\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>var</code> declarations can’t merge with <code>namespace</code>s).</p>\n<p>In TypeScript 3.7, the compiler will take advantage of this feature so that <code>.d.ts</code> files generated from <code>.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\" style=\"position:relative;\"><a href=\"#apis-to-support---build-and---incremental\" aria-label=\"apis to support   build and   incremental permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>APIs to Support <code>--build</code> and <code>--incremental</code></h2>\n<p>TypeScript 3.0 introduced support for referencing other and building them incrementally using the <code>--build</code> flag.\nAdditionally, TypeScript 3.4 introduced the <code>--incremental</code> flag for saving information about previous compilations to only rebuild certain files.\nThese flags were incredibly useful for structuring projects more flexibly and speeding builds up.\nUnfortunately, using these flags didn’t work with 3rd party build tools like Gulp and Webpack.\nTypeScript 3.6 now exposes two sets of APIs to operate on project references and incremental program building.</p>\n<p>For creating <code>--incremental</code> builds, users can leverage the <code>createIncrementalProgram</code> and <code>createIncrementalCompilerHost</code> APIs.\nUsers can also re-hydrate old program instances from <code>.tsbuildinfo</code> files generated by this API using the newly exposed <code>readBuilderProgram</code> function, which is only meant to be used as for creating new programs (i.e. you can’t modify the returned instance - it’s only meant to be used for the <code>oldProgram</code> parameter in other <code>create*Program</code> functions).</p>\n<p>For leveraging project references, a new <code>createSolutionBuilder</code> function has been exposed, which returns an instance of the new type <code>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=\"semicolon-aware-code-edits\" style=\"position:relative;\"><a href=\"#semicolon-aware-code-edits\" aria-label=\"semicolon aware code edits permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>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.\nThese 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’ 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.\nIf your file generally lacks semicolons, TypeScript won’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-import-syntax\" style=\"position:relative;\"><a href=\"#smarter-auto-import-syntax\" aria-label=\"smarter auto import syntax permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Smarter Auto-Import Syntax</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!\nFor 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>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.\nYou can <a href=\"https://github.com/microsoft/TypeScript/pull/32684\">see more details in the original pull request here</a>.</p>\n<h2 id=\"await-completions-on-promises\" style=\"position:relative;\"><a href=\"#await-completions-on-promises\" aria-label=\"await completions on promises permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>await</code> Completions on Promises</h2>\n<h2 id=\"new-typescript-playground\" style=\"position:relative;\"><a href=\"#new-typescript-playground\" aria-label=\"new typescript playground permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New TypeScript Playground</h2>\n<p>The TypeScript playground has received a much-needed refresh with handy new functionality!\nThe new playground is largely a fork of <a href=\"https://github.com/agentcooper\">Artem Tyurin</a>’s <a href=\"https://github.com/agentcooper/typescript-play\">TypeScript playground</a> which community members have been using more and more.\nWe 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>target</code> option (allowing users to switch out of <code>es5</code> to <code>es3</code>, <code>es2015</code>, <code>esnext</code>, etc.)</li>\n<li>All the strictness flags (including just <code>strict</code>)</li>\n<li>Support for plain JavaScript files (using <code>allowJS</code> and optionally <code>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 “oh, don’t forget to turn on the <code>noImplicitAny</code> option!“.</p>\n<p>In the near future, we’re going to be refreshing the playground samples, adding JSX support, and polishing automatic type acquisition, meaning that you’ll be able to see the same experience on the playground as you’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=\"typescript-35\" style=\"position:relative;\"><a href=\"#typescript-35\" aria-label=\"typescript 35 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 3.5</h2>\n<h2 id=\"speed-improvements\" style=\"position:relative;\"><a href=\"#speed-improvements\" aria-label=\"speed improvements permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Speed improvements</h2>\n<p>TypeScript 3.5 introduces several optimizations around type-checking and incremental builds.</p>\n<h3 id=\"type-checking-speed-ups\" style=\"position:relative;\"><a href=\"#type-checking-speed-ups\" aria-label=\"type checking speed ups permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Type-checking speed-ups</h3>\n<p>TypeScript 3.5 contains certain optimizations over TypeScript 3.4 for type-checking more efficiently.\nThese improvements are significantly more pronounced in editor scenarios where type-checking drives operations like code completion lists.</p>\n<h3 id=\"--incremental-improvements\" style=\"position:relative;\"><a href=\"#--incremental-improvements\" aria-label=\"  incremental improvements permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>--incremental</code> improvements</h3>\n<p>TypeScript 3.5 improves on 3.4’s <code>--incremental</code> build mode, by saving information about how the state of the world was calculated - compiler settings, why files were looked up, where files were found, etc.\nIn scenarios involving hundreds of projects using TypeScript’s project references in <code>--build</code> mode, <a href=\"https://github.com/Microsoft/TypeScript/pull/31101\">we’ve found that the amount of time rebuilding can be reduced by as much as 68% compared to TypeScript 3.4</a>!</p>\n<p>For more details, you can see the pull requests to</p>\n<ul>\n<li><a href=\"https://github.com/Microsoft/TypeScript/pull/31100\">cache module resolution</a></li>\n<li><a href=\"https://github.com/Microsoft/TypeScript/pull/31101\">cache settings calculated from <code>tsconfig.json</code></a></li>\n</ul>\n<h2 id=\"the-omit-helper-type\" style=\"position:relative;\"><a href=\"#the-omit-helper-type\" aria-label=\"the omit helper type permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The <code>Omit</code> helper type</h2>\n<p>TypeScript 3.5 introduces the new <code>Omit</code> helper type, which creates a new type with some properties dropped from the original.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Person = {</span>\n<span style=\"color: #000000\">  name: string;</span>\n<span style=\"color: #000000\">  age: number;</span>\n<span style=\"color: #000000\">  location: string;</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> QuantumPerson = Omit&lt;Person, </span><span style=\"color: #A31515\">\"location\"</span><span style=\"color: #000000\">&gt;;</span>\n\n<span style=\"color: #008000\">// equivalent to</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> QuantumPerson = {</span>\n<span style=\"color: #000000\">  name: string;</span>\n<span style=\"color: #000000\">  age: number;</span>\n<span style=\"color: #000000\">};</span></code></div></pre>\n<p>Here we were able to copy over all the properties of <code>Person</code> except for <code>location</code> using the <code>Omit</code> helper.</p>\n<p>For more details, <a href=\"https://github.com/Microsoft/TypeScript/pull/30552\">see the pull request on GitHub to add <code>Omit</code></a>, as well as <a href=\"https://github.com/microsoft/TypeScript/pull/31134\">the change to use <code>Omit</code> for object rest</a>.</p>\n<h3 id=\"improved-excess-property-checks-in-union-types\" style=\"position:relative;\"><a href=\"#improved-excess-property-checks-in-union-types\" aria-label=\"improved excess property checks in union types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Improved excess property checks in union types</h3>\n<p>In TypeScript 3.4 and earlier, certain excess properties were allowed in situations where they really shouldn’t have been.\nFor instance, TypeScript 3.4 permitted the incorrect <code>name</code> property in the object literal even though its types don’t match between <code>Point</code> and <code>Label</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Point = {</span>\n<span style=\"color: #000000\">  x: number;</span>\n<span style=\"color: #000000\">  y: number;</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Label = {</span>\n<span style=\"color: #000000\">  name: string;</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> thing: Point | Label = {</span>\n<span style=\"color: #000000\">  x: </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  y: </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  name: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\"> </span><span style=\"color: #008000\">// uh-oh!</span>\n<span style=\"color: #000000\">};</span></code></div></pre>\n<p>Previously, a non-disciminated union wouldn’t have <em>any</em> excess property checking done on its members, and as a result, the incorrectly typed <code>name</code> property slipped by.</p>\n<p>In TypeScript 3.5, the type-checker at least verifies that all the provided properties belong to <em>some</em> union member and have the appropriate type, meaning that the sample above correctly issues an error.</p>\n<p>Note that partial overlap is still permitted as long as the property types are valid.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> pl: Point | Label = {</span>\n<span style=\"color: #000000\">  x: </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  y: </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  name: </span><span style=\"color: #A31515\">\"origin\"</span><span style=\"color: #000000\"> </span><span style=\"color: #008000\">// okay</span>\n<span style=\"color: #000000\">};</span></code></div></pre>\n<h2 id=\"the---allowumdglobalaccess-flag\" style=\"position:relative;\"><a href=\"#the---allowumdglobalaccess-flag\" aria-label=\"the   allowumdglobalaccess flag permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The <code>--allowUmdGlobalAccess</code> flag</h2>\n<p>In TypeScript 3.5, you can now reference UMD global declarations like</p>\n<pre><code>export as namespace foo;\n</code></pre>\n<p>from anywhere - even modules - using the new <code>--allowUmdGlobalAccess</code> flag.</p>\n<p>This mode adds flexibility for mixing and matching the way 3rd party libraries, where globals that libraries declare can always be consumed, even from within modules.</p>\n<p>For more details, <a href=\"https://github.com/Microsoft/TypeScript/pull/30776/files\">see the pull request on GitHub</a>.</p>\n<h2 id=\"smarter-union-type-checking\" style=\"position:relative;\"><a href=\"#smarter-union-type-checking\" aria-label=\"smarter union type checking permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Smarter union type checking</h2>\n<p>In TypeScript 3.4 and prior, the following example would fail:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> S = { done: boolean; value: number };</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T = { done: false; value: number } | { done: true; value: number };</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> source: S;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> target: T;</span>\n\n<span style=\"color: #000000\">target = source;</span></code></div></pre>\n<p>That’s because <code>S</code> isn’t assignable to <code>{ done: false, value: number }</code> nor <code>{ done: true, value: number }</code>.\nWhy?\nBecause the <code>done</code> property in <code>S</code> isn’t specific enough - it’s <code>boolean</code> whereas each constituent of <code>T</code> has a <code>done</code> property that’s specifically <code>true</code> or <code>false</code>.\nThat’s what we meant by each constituent type being checked in isolation: TypeScript doesn’t just union each property together and see if <code>S</code> is assignable to that.\nIf it did, some bad code could get through like the following:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Foo {</span>\n<span style=\"color: #000000\">  kind: </span><span style=\"color: #A31515\">\"foo\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  value: string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Bar {</span>\n<span style=\"color: #000000\">  kind: </span><span style=\"color: #A31515\">\"bar\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  value: number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> doSomething(x: Foo | Bar) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (x.kind === </span><span style=\"color: #A31515\">\"foo\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    x.value.toLowerCase();</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// uh-oh - luckily TypeScript errors here!</span>\n<span style=\"color: #000000\">doSomething({</span>\n<span style=\"color: #000000\">  kind: </span><span style=\"color: #A31515\">\"foo\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  value: </span><span style=\"color: #09835A\">123</span>\n<span style=\"color: #000000\">});</span></code></div></pre>\n<p>However, this was a bit overly strict for the original example.\nIf you figure out the precise type of any possible value of <code>S</code>, you can actually see that it matches the types in <code>T</code> exactly.</p>\n<p>In TypeScript 3.5, when assigning to types with discriminant properties like in <code>T</code>, the language actually <em>will</em> go further and decompose types like <code>S</code> into a union of every possible inhabitant type.\nIn this case, since <code>boolean</code> is a union of <code>true</code> and <code>false</code>, <code>S</code> will be viewed as a union of <code>{ done: false, value: number }</code> and <code>{ done: true, value: number }</code>.</p>\n<p>For more details, you can <a href=\"https://github.com/microsoft/TypeScript/pull/30779\">see the original pull request on GitHub</a>.</p>\n<h2 id=\"higher-order-type-inference-from-generic-constructors\" style=\"position:relative;\"><a href=\"#higher-order-type-inference-from-generic-constructors\" aria-label=\"higher order type inference from generic constructors permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Higher order type inference from generic constructors</h2>\n<p>In TypeScript 3.4, we improved inference for when generic functions that return functions like so:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> compose&lt;T, U, V&gt;(f: (x: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> U, g: (y: U) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> V): (x: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> V {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> g(f(x));</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>took other generic functions as arguments, like so:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> arrayify&lt;T&gt;(x: T): T[] {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> [x];</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Box&lt;U&gt; = { value: U };</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> boxify&lt;U&gt;(y: U): Box&lt;U&gt; {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> { value: y };</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> newFn = compose(arrayify, boxify);</span></code></div></pre>\n<p>Instead of a relatively useless type like <code>(x: {}) => Box&#x3C;{}[]></code>, which older versions of the language would infer, TypeScript 3.4’s inference allows <code>newFn</code> to be generic.\nIts new type is <code>&#x3C;T>(x: T) => Box&#x3C;T[]></code>.</p>\n<p>TypeScript 3.5 generalizes this behavior to work on constructor functions as well.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Box&lt;T&gt; {</span>\n<span style=\"color: #000000\">  kind: </span><span style=\"color: #A31515\">\"box\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  value: T;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(value: T) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.value = value;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Bag&lt;U&gt; {</span>\n<span style=\"color: #000000\">  kind: </span><span style=\"color: #A31515\">\"bag\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  value: U;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(value: U) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.value = value;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> composeCtor&lt;T, U, V&gt;(</span>\n<span style=\"color: #000000\">  F: </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> (x: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> U,</span>\n<span style=\"color: #000000\">  G: </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> (y: U) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> V</span>\n<span style=\"color: #000000\">): (x: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> V {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> G(</span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> F(x));</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> f = composeCtor(Box, Bag); </span><span style=\"color: #008000\">// has type '&lt;T&gt;(x: T) =&gt; Bag&lt;Box&lt;T&gt;&gt;'</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> a = f(</span><span style=\"color: #09835A\">1024</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// has type 'Bag&lt;Box&lt;number&gt;&gt;'</span></code></div></pre>\n<p>In addition to compositional patterns like the above, this new inference on generic constructors means that functions that operate on class components in certain UI libraries like React can more correctly operate on generic class components.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> ComponentClass&lt;P&gt; = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> (props: P) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> Component&lt;P&gt;;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Component&lt;P&gt; {</span>\n<span style=\"color: #000000\">  props: P;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(props: P);</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> myHoc&lt;P&gt;(C: ComponentClass&lt;P&gt;): ComponentClass&lt;P&gt;;</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> NestedProps&lt;T&gt; = { foo: number; stuff: T };</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> GenericComponent&lt;T&gt; </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Component&lt;NestedProps&lt;T&gt;&gt; {}</span>\n\n<span style=\"color: #008000\">// type is 'new &lt;T&gt;(props: NestedProps&lt;T&gt;) =&gt; Component&lt;NestedProps&lt;T&gt;&gt;'</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> GenericComponent2 = myHoc(GenericComponent);</span></code></div></pre>\n<p>To learn more, <a href=\"https://github.com/microsoft/TypeScript/pull/31116\">check out the original pull request on GitHub</a>.</p>\n<h2 id=\"typescript-34\" style=\"position:relative;\"><a href=\"#typescript-34\" aria-label=\"typescript 34 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 3.4</h2>\n<h2 id=\"faster-subsequent-builds-with-the---incremental-flag\" style=\"position:relative;\"><a href=\"#faster-subsequent-builds-with-the---incremental-flag\" aria-label=\"faster subsequent builds with the   incremental flag permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Faster subsequent builds with the <code>--incremental</code> flag</h2>\n<p>TypeScript 3.4 introduces a new flag called <code>--incremental</code> which tells TypeScript to save information about the project graph from the last compilation.\nThe next time TypeScript is invoked with <code>--incremental</code>, it will use that information to detect the least costly way to type-check and emit changes to your project.</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #008000\">// tsconfig.json</span>\n<span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #CD3131\">compilerOptions</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #CD3131\">incremental</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #CD3131\">outDir</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./lib\"</span>\n<span style=\"color: #000000\">  },</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #CD3131\">include</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"./src\"</span><span style=\"color: #000000\">]</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>By default with these settings, when we run <code>tsc</code>, TypeScript will look for a file called <code>.tsbuildinfo</code> in the output directory (<code>./lib</code>).\nIf <code>./lib/.tsbuildinfo</code> doesn’t exist, it’ll be generated.\nBut if it does, <code>tsc</code> will try to use that file to incrementally type-check and update our output files.</p>\n<p>These <code>.tsbuildinfo</code> files can be safely deleted and don’t have any impact on our code at runtime - they’re purely used to make compilations faster.\nWe can also name them anything that we want, and place them anywhere we want using the <code>--tsBuildInfoFile</code> flag.</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #008000\">// front-end.tsconfig.json</span>\n<span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #CD3131\">compilerOptions</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #CD3131\">incremental</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #CD3131\">tsBuildInfoFile</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./buildcache/front-end\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #CD3131\">outDir</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./lib\"</span>\n<span style=\"color: #000000\">  },</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #CD3131\">include</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"./src\"</span><span style=\"color: #000000\">]</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h3 id=\"composite-projects\" style=\"position:relative;\"><a href=\"#composite-projects\" aria-label=\"composite projects permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Composite projects</h3>\n<p>Part of the intent with composite projects (<code>tsconfig.json</code>s with <code>composite</code> set to <code>true</code>) is that references between different projects can be built incrementally.\nAs such, composite projects will <strong>always</strong> produce <code>.tsbuildinfo</code> files.</p>\n<h3 id=\"outfile\" style=\"position:relative;\"><a href=\"#outfile\" aria-label=\"outfile permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>outFile</code></h3>\n<p>When <code>outFile</code> is used, the build information file’s name will be based on the output file’s name.\nAs an example, if our output JavaScript file is <code>./output/foo.js</code>, then under the <code>--incremental</code> flag, TypeScript will generate the file <code>./output/foo.tsbuildinfo</code>.\nAs above, this can be controlled with the <code>--tsBuildInfoFile</code> flag.</p>\n<h2 id=\"higher-order-type-inference-from-generic-functions\" style=\"position:relative;\"><a href=\"#higher-order-type-inference-from-generic-functions\" aria-label=\"higher order type inference from generic functions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Higher order type inference from generic functions</h2>\n<p>TypeScript 3.4 can now produce generic function types when inference from other generic functions produces free type variables for inferences.\nThis means many function composition patterns now work better in 3.4.</p>\n<p>To get more specific, let’s build up some motivation and consider the following <code>compose</code> function:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> compose&lt;A, B, C&gt;(f: (arg: A) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> B, g: (arg: B) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> C): (arg: A) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> g(f(x));</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p><code>compose</code> takes two other functions:</p>\n<ul>\n<li><code>f</code> which takes some argument (of type <code>A</code>) and returns a value of type <code>B</code></li>\n<li><code>g</code> which takes an argument of type <code>B</code> (the type <code>f</code> returned), and returns a value of type <code>C</code></li>\n</ul>\n<p><code>compose</code> then returns a function which feeds its argument through <code>f</code> and then <code>g</code>.</p>\n<p>When calling this function, TypeScript will try to figure out the types of <code>A</code>, <code>B</code>, and <code>C</code> through a process called <em>type argument inference</em>.\nThis inference process usually works pretty well:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Person {</span>\n<span style=\"color: #000000\">  name: string;</span>\n<span style=\"color: #000000\">  age: number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> getDisplayName(p: Person) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> p.name.toLowerCase();</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> getLength(s: string) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> s.length;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// has type '(p: Person) =&gt; number'</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> getDisplayNameLength = compose(getDisplayName, getLength);</span>\n\n<span style=\"color: #008000\">// works and returns the type 'number'</span>\n<span style=\"color: #000000\">getDisplayNameLength({ name: </span><span style=\"color: #A31515\">\"Person McPersonface\"</span><span style=\"color: #000000\">, age: </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\"> });</span></code></div></pre>\n<p>The inference process is fairly straightforward here because <code>getDisplayName</code> and <code>getLength</code> use types that can easily be referenced.\nHowever, in TypeScript 3.3 and earlier, generic functions like <code>compose</code> didn’t work so well when passed other generic functions.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Box&lt;T&gt; {</span>\n<span style=\"color: #000000\">  value: T;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> makeArray&lt;T&gt;(x: T): T[] {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> [x];</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> makeBox&lt;U&gt;(value: U): Box&lt;U&gt; {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> { value };</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// has type '(arg: {}) =&gt; Box&lt;{}[]&gt;'</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> makeBoxedArray = compose(makeArray, makeBox);</span>\n\n<span style=\"color: #000000\">makeBoxedArray(</span><span style=\"color: #A31515\">\"hello!\"</span><span style=\"color: #000000\">).value[</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">].toUpperCase();</span>\n<span style=\"color: #008000\">//                                ~~~~~~~~~~~</span>\n<span style=\"color: #008000\">// error: Property 'toUpperCase' does not exist on type '{}'.</span></code></div></pre>\n<p>In older versions, TypeScript would infer the empty object type (<code>{}</code>) when inferring from other type variables like <code>T</code> and <code>U</code>.</p>\n<p>During type argument inference in TypeScript 3.4, for a call to a generic function that returns a function type, TypeScript <em>will</em>, as appropriate, propagate type parameters from generic function arguments onto the resulting function type.</p>\n<p>In other words, instead of producing the type</p>\n<pre><code>(arg: {}) => Box&#x3C;{}[]>\n</code></pre>\n<p>TypeScript 3.4 produces the type</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #000000\">&lt;T&gt;(arg: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> Box&lt;T[]&gt;</span></code></div></pre>\n<p>Notice that <code>T</code> has been propagated from <code>makeArray</code> into the resulting type’s type parameter list.\nThis means that genericity from <code>compose</code>’s arguments has been preserved and our <code>makeBoxedArray</code> sample will just work!</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Box&lt;T&gt; {</span>\n<span style=\"color: #000000\">  value: T;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> makeArray&lt;T&gt;(x: T): T[] {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> [x];</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> makeBox&lt;U&gt;(value: U): Box&lt;U&gt; {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> { value };</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// has type '&lt;T&gt;(arg: T) =&gt; Box&lt;T[]&gt;'</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> makeBoxedArray = compose(makeArray, makeBox);</span>\n\n<span style=\"color: #008000\">// works with no problem!</span>\n<span style=\"color: #000000\">makeBoxedArray(</span><span style=\"color: #A31515\">\"hello!\"</span><span style=\"color: #000000\">).value[</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">].toUpperCase();</span></code></div></pre>\n<p>For more details, you can <a href=\"https://github.com/Microsoft/TypeScript/pull/30215\">read more at the original change</a>.</p>\n<h2 id=\"improvements-for-readonlyarray-and-readonly-tuples\" style=\"position:relative;\"><a href=\"#improvements-for-readonlyarray-and-readonly-tuples\" aria-label=\"improvements for readonlyarray and readonly tuples permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Improvements for <code>ReadonlyArray</code> and <code>readonly</code> tuples</h2>\n<p>TypeScript 3.4 makes it a little bit easier to use read-only array-like types.</p>\n<h3 id=\"a-new-syntax-for-readonlyarray\" style=\"position:relative;\"><a href=\"#a-new-syntax-for-readonlyarray\" aria-label=\"a new syntax for readonlyarray permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>A new syntax for <code>ReadonlyArray</code></h3>\n<p>The <code>ReadonlyArray</code> type describes <code>Array</code>s that can only be read from.\nAny variable with a reference to a <code>ReadonlyArray</code> can’t add, remove, or replace any elements of the array.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> foo(arr: ReadonlyArray&lt;string&gt;) {</span>\n<span style=\"color: #000000\">  arr.slice(); </span><span style=\"color: #008000\">// okay</span>\n<span style=\"color: #000000\">  arr.push(</span><span style=\"color: #A31515\">\"hello!\"</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// error!</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>While it’s good practice to use <code>ReadonlyArray</code> over <code>Array</code> when no mutation is intended, it’s often been a pain given that arrays have a nicer syntax.\nSpecifically, <code>number[]</code> is a shorthand version of <code>Array&#x3C;number></code>, just as <code>Date[]</code> is a shorthand for <code>Array&#x3C;Date></code>.</p>\n<p>TypeScript 3.4 introduces a new syntax for <code>ReadonlyArray</code> using a new <code>readonly</code> modifier for array types.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> foo(arr: readonly string[]) {</span>\n<span style=\"color: #000000\">  arr.slice(); </span><span style=\"color: #008000\">// okay</span>\n<span style=\"color: #000000\">  arr.push(</span><span style=\"color: #A31515\">\"hello!\"</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// error!</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h3 id=\"readonly-tuples\" style=\"position:relative;\"><a href=\"#readonly-tuples\" aria-label=\"readonly tuples permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>readonly</code> tuples</h3>\n<p>TypeScript 3.4 also introduces new support for <code>readonly</code> tuples.\nWe can prefix any tuple type with the <code>readonly</code> keyword to make it a <code>readonly</code> tuple, much like we now can with array shorthand syntax.\nAs you might expect, unlike ordinary tuples whose slots could be written to, <code>readonly</code> tuples only permit reading from those positions.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> foo(pair: readonly [string, string]) {</span>\n<span style=\"color: #000000\">  console.log(pair[</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">]); </span><span style=\"color: #008000\">// okay</span>\n<span style=\"color: #000000\">  pair[</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">] = </span><span style=\"color: #A31515\">\"hello!\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// error</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>The same way that ordinary tuples are types that extend from <code>Array</code> - a tuple with elements of type <code>T</code><sub><code>1</code></sub>, <code>T</code><sub><code>2</code></sub>, … <code>T</code><sub><code>n</code></sub> extends from <code>Array&#x3C;</code> <code>T</code><sub><code>1</code></sub> | <code>T</code><sub><code>2</code></sub> | … <code>T</code><sub><code>n</code></sub> <code>></code> - <code>readonly</code> tuples are types that extend from <code>ReadonlyArray</code>. So a <code>readonly</code> tuple with elements <code>T</code><sub><code>1</code></sub>, <code>T</code><sub><code>2</code></sub>, … <code>T</code><sub><code>n</code></sub> extends from <code>ReadonlyArray&#x3C;</code> <code>T</code><sub><code>1</code></sub> | <code>T</code><sub><code>2</code></sub> | … <code>T</code><sub><code>n</code></sub> <code>></code>.</p>\n<h3 id=\"readonly-mapped-type-modifiers-and-readonly-arrays\" style=\"position:relative;\"><a href=\"#readonly-mapped-type-modifiers-and-readonly-arrays\" aria-label=\"readonly mapped type modifiers and readonly arrays permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>readonly</code> mapped type modifiers and <code>readonly</code> arrays</h3>\n<p>In earlier versions of TypeScript, we generalized mapped types to operate differently on array-like types.\nThis meant that a mapped type like <code>Boxify</code> could work on arrays and tuples alike.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Box&lt;T&gt; {</span>\n<span style=\"color: #000000\">  value: T;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Boxify&lt;T&gt; = {</span>\n<span style=\"color: #000000\">  [K </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> keyof T]: Box&lt;T[K]&gt;;</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #008000\">// { a: Box&lt;string&gt;, b: Box&lt;number&gt; }</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> A = Boxify&lt;{ a: string; b: number }&gt;;</span>\n\n<span style=\"color: #008000\">// Array&lt;Box&lt;number&gt;&gt;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> B = Boxify&lt;number[]&gt;;</span>\n\n<span style=\"color: #008000\">// [Box&lt;string&gt;, Box&lt;number&gt;]</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> C = Boxify&lt;[string, boolean]&gt;;</span></code></div></pre>\n<p>Unfortunately, mapped types like the <code>Readonly</code> utility type were effectively no-ops on array and tuple types.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// lib.d.ts</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Readonly&lt;T&gt; = {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">readonly</span><span style=\"color: #000000\"> [K </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> keyof T]: T[K];</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #008000\">// How code acted *before* TypeScript 3.4</span>\n\n<span style=\"color: #008000\">// { readonly a: string, readonly b: number }</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> A = Readonly&lt;{ a: string; b: number }&gt;;</span>\n\n<span style=\"color: #008000\">// number[]</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> B = Readonly&lt;number[]&gt;;</span>\n\n<span style=\"color: #008000\">// [string, boolean]</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> C = Readonly&lt;[string, boolean]&gt;;</span></code></div></pre>\n<p>In TypeScript 3.4, the <code>readonly</code> modifier in a mapped type will automatically convert array-like types to their corresponding <code>readonly</code> counterparts.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// How code acts now *with* TypeScript 3.4</span>\n\n<span style=\"color: #008000\">// { readonly a: string, readonly b: number }</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> A = Readonly&lt;{ a: string; b: number }&gt;;</span>\n\n<span style=\"color: #008000\">// readonly number[]</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> B = Readonly&lt;number[]&gt;;</span>\n\n<span style=\"color: #008000\">// readonly [string, boolean]</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> C = Readonly&lt;[string, boolean]&gt;;</span></code></div></pre>\n<p>Similarly, you could write a utility type like <code>Writable</code> mapped type that strips away <code>readonly</code>-ness, and that would convert <code>readonly</code> array containers back to their mutable equivalents.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Writable&lt;T&gt; = {</span>\n<span style=\"color: #000000\">  -</span><span style=\"color: #0000FF\">readonly</span><span style=\"color: #000000\"> [K </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> keyof T]: T[K];</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #008000\">// { a: string, b: number }</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> A = Writable&lt;{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">readonly</span><span style=\"color: #000000\"> a: string;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">readonly</span><span style=\"color: #000000\"> b: number;</span>\n<span style=\"color: #000000\">}&gt;;</span>\n\n<span style=\"color: #008000\">// number[]</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> B = Writable&lt;readonly number[]&gt;;</span>\n\n<span style=\"color: #008000\">// [string, boolean]</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> C = Writable&lt;readonly [string, boolean]&gt;;</span></code></div></pre>\n<h3 id=\"caveats\" style=\"position:relative;\"><a href=\"#caveats\" aria-label=\"caveats permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Caveats</h3>\n<p>Despite its appearance, the <code>readonly</code> type modifier can only be used for syntax on array types and tuple types.\nIt is not a general-purpose type operator.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> err1: readonly Set&lt;number&gt;; </span><span style=\"color: #008000\">// error!</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> err2: readonly Array&lt;boolean&gt;; </span><span style=\"color: #008000\">// error!</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> okay: readonly boolean[]; </span><span style=\"color: #008000\">// works fine</span></code></div></pre>\n<p>You can <a href=\"https://github.com/Microsoft/TypeScript/pull/29435\">see more details in the pull request</a>.</p>\n<h2 id=\"const-assertions\" style=\"position:relative;\"><a href=\"#const-assertions\" aria-label=\"const assertions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>const</code> assertions</h2>\n<p>TypeScript 3.4 introduces a new construct for literal values called <em><code>const</code></em> assertions.\nIts syntax is a type assertion with <code>const</code> in place of the type name (e.g. <code>123 as const</code>).\nWhen we construct new literal expressions with <code>const</code> assertions, we can signal to the language that</p>\n<ul>\n<li>no literal types in that expression should be widened (e.g. no going from <code>\"hello\"</code> to <code>string</code>)</li>\n<li>object literals get <code>readonly</code> properties</li>\n<li>array literals become <code>readonly</code> tuples</li>\n</ul>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Type '\"hello\"'</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> const;</span>\n\n<span style=\"color: #008000\">// Type 'readonly [10, 20]'</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> y = [</span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">20</span><span style=\"color: #000000\">] </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> const;</span>\n\n<span style=\"color: #008000\">// Type '{ readonly text: \"hello\" }'</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> z = { text: </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\"> } </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> const;</span></code></div></pre>\n<p>Outside of <code>.tsx</code> files, the angle bracket assertion syntax can also be used.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Type '\"hello\"'</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = &lt;const&gt;</span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #008000\">// Type 'readonly [10, 20]'</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> y = &lt;const&gt;[</span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">20</span><span style=\"color: #000000\">];</span>\n\n<span style=\"color: #008000\">// Type '{ readonly text: \"hello\" }'</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> z = &lt;const&gt;{ text: </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\"> };</span></code></div></pre>\n<p>This feature means that types that would otherwise be used just to hint immutability to the compiler can often be omitted.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Works with no types referenced or declared.</span>\n<span style=\"color: #008000\">// We only needed a single const assertion.</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> getShapes() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> result = [</span>\n<span style=\"color: #000000\">    { kind: </span><span style=\"color: #A31515\">\"circle\"</span><span style=\"color: #000000\">, radius: </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\"> },</span>\n<span style=\"color: #000000\">    { kind: </span><span style=\"color: #A31515\">\"square\"</span><span style=\"color: #000000\">, sideLength: </span><span style=\"color: #09835A\">50</span><span style=\"color: #000000\"> }</span>\n<span style=\"color: #000000\">  ] </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> const;</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> result;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> shape </span><span style=\"color: #0000FF\">of</span><span style=\"color: #000000\"> getShapes()) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Narrows perfectly!</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (shape.kind === </span><span style=\"color: #A31515\">\"circle\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    console.log(</span><span style=\"color: #A31515\">\"Circle radius\"</span><span style=\"color: #000000\">, shape.radius);</span>\n<span style=\"color: #000000\">  } </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    console.log(</span><span style=\"color: #A31515\">\"Square side length\"</span><span style=\"color: #000000\">, shape.sideLength);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Notice the above needed no type annotations.\nThe <code>const</code> assertion allowed TypeScript to take the most specific type of the expression.</p>\n<p>This can even be used to enable <code>enum</code>-like patterns in plain JavaScript code if you choose not to use TypeScript’s <code>enum</code> construct.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> Colors = {</span>\n<span style=\"color: #000000\">  red: </span><span style=\"color: #A31515\">\"RED\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  blue: </span><span style=\"color: #A31515\">\"BLUE\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  green: </span><span style=\"color: #A31515\">\"GREEN\"</span>\n<span style=\"color: #000000\">} </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> const;</span>\n\n<span style=\"color: #008000\">// or use an 'export default'</span>\n\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">default</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">  red: </span><span style=\"color: #A31515\">\"RED\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  blue: </span><span style=\"color: #A31515\">\"BLUE\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  green: </span><span style=\"color: #A31515\">\"GREEN\"</span>\n<span style=\"color: #000000\">} </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> const;</span></code></div></pre>\n<h3 id=\"caveats-1\" style=\"position:relative;\"><a href=\"#caveats-1\" aria-label=\"caveats 1 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Caveats</h3>\n<p>One thing to note is that <code>const</code> assertions can only be applied immediately on simple literal expressions.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Error! A 'const' assertion can only be applied to a</span>\n<span style=\"color: #008000\">// to a string, number, boolean, array, or object literal.</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> a = (Math.random() &lt; </span><span style=\"color: #09835A\">0.5</span><span style=\"color: #000000\"> ? </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\"> : </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">) </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> const;</span>\n\n<span style=\"color: #008000\">// Works!</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> b = Math.random() &lt; </span><span style=\"color: #09835A\">0.5</span><span style=\"color: #000000\"> ? (</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> const) : (</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> const);</span></code></div></pre>\n<p>Another thing to keep in mind is that <code>const</code> contexts don’t immediately convert an expression to be fully immutable.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> arr = [</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">4</span><span style=\"color: #000000\">];</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> foo = {</span>\n<span style=\"color: #000000\">  name: </span><span style=\"color: #A31515\">\"foo\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  contents: arr</span>\n<span style=\"color: #000000\">} </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> const;</span>\n\n<span style=\"color: #000000\">foo.name = </span><span style=\"color: #A31515\">\"bar\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// error!</span>\n<span style=\"color: #000000\">foo.contents = []; </span><span style=\"color: #008000\">// error!</span>\n\n<span style=\"color: #000000\">foo.contents.push(</span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// ...works!</span></code></div></pre>\n<p>For more details, you can <a href=\"https://github.com/Microsoft/TypeScript/pull/29510\">check out the respective pull request</a>.</p>\n<h2 id=\"type-checking-for-globalthis\" style=\"position:relative;\"><a href=\"#type-checking-for-globalthis\" aria-label=\"type checking for globalthis permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Type-checking for <code>globalThis</code></h2>\n<p>TypeScript 3.4 introduces support for type-checking ECMAScript’s new <code>globalThis</code> - a global variable that, well, refers to the global scope.\nUnlike the above solutions, <code>globalThis</code> provides a standard way for accessing the global scope which can be used across different environments.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// in a global file:</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> abc = </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #008000\">// Refers to 'abc' from above.</span>\n<span style=\"color: #000000\">globalThis.abc = </span><span style=\"color: #09835A\">200</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>Note that global variables declared with <code>let</code> and <code>const</code> don’t show up on <code>globalThis</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> answer = </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #008000\">// error! Property 'answer' does not exist on 'typeof globalThis'.</span>\n<span style=\"color: #000000\">globalThis.answer = </span><span style=\"color: #09835A\">333333</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>It’s also important to note that TypeScript doesn’t transform references to <code>globalThis</code> when compiling to older versions of ECMAScript.\nAs such, unless you’re targeting evergreen browsers (which already support <code>globalThis</code>), you may want to <a href=\"https://github.com/ljharb/globalThis\">use an appropriate polyfill</a> instead.</p>\n<p>For more details on the implementation, see <a href=\"https://github.com/Microsoft/TypeScript/pull/29332\">the feature’s pull request</a>.</p>\n<h2 id=\"typescript-33\" style=\"position:relative;\"><a href=\"#typescript-33\" aria-label=\"typescript 33 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 3.3</h2>\n<h2 id=\"improved-behavior-for-calling-union-types\" style=\"position:relative;\"><a href=\"#improved-behavior-for-calling-union-types\" aria-label=\"improved behavior for calling union types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Improved behavior for calling union types</h2>\n<p>In prior versions of TypeScript, unions of callable types could <em>only</em> be invoked if they had identical parameter lists.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Fruit = </span><span style=\"color: #A31515\">\"apple\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"orange\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Color = </span><span style=\"color: #A31515\">\"red\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"orange\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> FruitEater = (fruit: Fruit) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> number; </span><span style=\"color: #008000\">// eats and ranks the fruit</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> ColorConsumer = (color: Color) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> string; </span><span style=\"color: #008000\">// consumes and describes the colors</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> f: FruitEater | ColorConsumer;</span>\n\n<span style=\"color: #008000\">// Cannot invoke an expression whose type lacks a call signature.</span>\n<span style=\"color: #008000\">//   Type 'FruitEater | ColorConsumer' has no compatible call signatures.ts(2349)</span>\n<span style=\"color: #000000\">f(</span><span style=\"color: #A31515\">\"orange\"</span><span style=\"color: #000000\">);</span></code></div></pre>\n<p>However, in the above example, both <code>FruitEater</code>s and <code>ColorConsumer</code>s should be able to take the string <code>\"orange\"</code>, and return either a <code>number</code> or a <code>string</code>.</p>\n<p>In TypeScript 3.3, this is no longer an error.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Fruit = </span><span style=\"color: #A31515\">\"apple\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"orange\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Color = </span><span style=\"color: #A31515\">\"red\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"orange\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> FruitEater = (fruit: Fruit) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> number; </span><span style=\"color: #008000\">// eats and ranks the fruit</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> ColorConsumer = (color: Color) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> string; </span><span style=\"color: #008000\">// consumes and describes the colors</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> f: FruitEater | ColorConsumer;</span>\n\n<span style=\"color: #000000\">f(</span><span style=\"color: #A31515\">\"orange\"</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// It works! Returns a 'number | string'.</span>\n\n<span style=\"color: #000000\">f(</span><span style=\"color: #A31515\">\"apple\"</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// error - Argument of type '\"red\"' is not assignable to parameter of type '\"orange\"'.</span>\n\n<span style=\"color: #000000\">f(</span><span style=\"color: #A31515\">\"red\"</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// error - Argument of type '\"red\"' is not assignable to parameter of type '\"orange\"'.</span></code></div></pre>\n<p>In TypeScript 3.3, the parameters of these signatures are <em>intersected</em> together to create a new signature.</p>\n<p>In the example above, the parameters <code>fruit</code> and <code>color</code> are intersected together to a new parameter of type <code>Fruit &#x26; Color</code>.\n<code>Fruit &#x26; Color</code> is really the same as <code>(\"apple\" | \"orange\") &#x26; (\"red\" | \"orange\")</code> which is equivalent to <code>(\"apple\" &#x26; \"red\") | (\"apple\" &#x26; \"orange\") | (\"orange\" &#x26; \"red\") | (\"orange\" &#x26; \"orange\")</code>.\nEach of those impossible intersections reduces to <code>never</code>, and we’re left with <code>\"orange\" &#x26; \"orange\"</code> which is just <code>\"orange\"</code>.</p>\n<h3 id=\"caveats-2\" style=\"position:relative;\"><a href=\"#caveats-2\" aria-label=\"caveats 2 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Caveats</h3>\n<p>This new behavior only kicks in when at most one type in the union has multiple overloads, and at most one type in the union has a generic signature.\nThat means methods on <code>number[] | string[]</code> like <code>map</code> (which is generic) still won’t be callable.</p>\n<p>On the other hand, methods like <code>forEach</code> will now be callable, but under <code>noImplicitAny</code> there may be some issues.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Dog {</span>\n<span style=\"color: #000000\">  kind: </span><span style=\"color: #A31515\">\"dog\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  dogProp: any;</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Cat {</span>\n<span style=\"color: #000000\">  kind: </span><span style=\"color: #A31515\">\"cat\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  catProp: any;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> catOrDogArray: Dog[] | Cat[] = [];</span>\n\n<span style=\"color: #000000\">catOrDogArray.forEach(animal </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//                ~~~~~~ error!</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Parameter 'animal' implicitly has an 'any' type.</span>\n<span style=\"color: #000000\">});</span></code></div></pre>\n<p>This is still strictly more capable in TypeScript 3.3, and adding an explicit type annotation will work.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Dog {</span>\n<span style=\"color: #000000\">  kind: </span><span style=\"color: #A31515\">\"dog\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  dogProp: any;</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Cat {</span>\n<span style=\"color: #000000\">  kind: </span><span style=\"color: #A31515\">\"cat\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  catProp: any;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> catOrDogArray: Dog[] | Cat[] = [];</span>\n<span style=\"color: #000000\">catOrDogArray.forEach((animal: Dog | Cat) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (animal.kind === </span><span style=\"color: #A31515\">\"dog\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    animal.dogProp;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// ...</span>\n<span style=\"color: #000000\">  } </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (animal.kind === </span><span style=\"color: #A31515\">\"cat\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    animal.catProp;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// ...</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">});</span></code></div></pre>\n<h2 id=\"incremental-file-watching-for-composite-projects-in---build---watch\" style=\"position:relative;\"><a href=\"#incremental-file-watching-for-composite-projects-in---build---watch\" aria-label=\"incremental file watching for composite projects in   build   watch permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Incremental file watching for composite projects in <code>--build --watch</code></h2>\n<p>TypeScript 3.0 introduced a new feature for structuring builds called “composite projects”.\nPart of the goal here was to ensure users could break up large projects into smaller parts that build quickly and preserve project structure, without compromising the existing TypeScript experience.\nThanks to composite projects, TypeScript can use <code>--build</code> mode to recompile only the set of projects and dependencies.\nYou can think of this as optimizing <em>inter</em>-project builds.</p>\n<p>TypeScript 2.7 also introduced <code>--watch</code> mode builds via a new incremental “builder” API.\nIn a similar vein, the entire idea is that this mode only re-checks and re-emits changed files or files whose dependencies might impact type-checking.\nYou can think of this as optimizing <em>intra</em>-project builds.</p>\n<p>Prior to 3.3, building composite projects using <code>--build --watch</code> actually didn’t use this incremental file watching infrastructure.\nAn update in one project under <code>--build --watch</code> mode would force a full build of that project, rather than determining which files within that project were affected.</p>\n<p>In TypeScript 3.3, <code>--build</code> mode’s <code>--watch</code> flag <em>does</em> leverage incremental file watching as well.\nThat can mean signficantly faster builds under <code>--build --watch</code>.\nIn our testing, this functionality has resulted in <strong>a reduction of 50% to 75% in build times</strong> of the original <code>--build --watch</code> times.\n<a href=\"https://github.com/Microsoft/TypeScript/pull/29161\">You can read more on the original pull request for the change</a> to see specific numbers, but we believe most composite project users will see significant wins here.</p>\n<h2 id=\"typescript-32\" style=\"position:relative;\"><a href=\"#typescript-32\" aria-label=\"typescript 32 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 3.2</h2>\n<h2 id=\"strictbindcallapply\" style=\"position:relative;\"><a href=\"#strictbindcallapply\" aria-label=\"strictbindcallapply permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>strictBindCallApply</code></h2>\n<p>TypeScript 3.2 introduces a new <code>--strictBindCallApply</code> compiler option (in the <code>--strict</code> family of options) with which the <code>bind</code>, <code>call</code>, and <code>apply</code> methods on function objects are strongly typed and strictly checked.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> foo(a: number, b: string): string {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> a + b;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> a = foo.apply(</span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">, [</span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">]); </span><span style=\"color: #008000\">// error: too few argumnts</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> b = foo.apply(</span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">, [</span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">20</span><span style=\"color: #000000\">]); </span><span style=\"color: #008000\">// error: 2nd argument is a number</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> c = foo.apply(</span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">, [</span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">30</span><span style=\"color: #000000\">]); </span><span style=\"color: #008000\">// error: too many arguments</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> d = foo.apply(</span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">, [</span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">]); </span><span style=\"color: #008000\">// okay! returns a string</span></code></div></pre>\n<p>This is achieved by introducing two new types, <code>CallableFunction</code> and <code>NewableFunction</code>, in <code>lib.d.ts</code>. These types contain specialized generic method declarations for <code>bind</code>, <code>call</code>, and <code>apply</code> for regular functions and constructor functions, respectively. The declarations use generic rest parameters (see #24897) to capture and reflect parameter lists in a strongly typed manner. In <code>--strictBindCallApply</code> mode these declarations are used in place of the (very permissive) declarations provided by type <code>Function</code>.</p>\n<h3 id=\"caveats-3\" style=\"position:relative;\"><a href=\"#caveats-3\" aria-label=\"caveats 3 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Caveats</h3>\n<p>Since the stricter checks may uncover previously unreported errors, this is a breaking change in <code>--strict</code> mode.</p>\n<p>Additionally, <a href=\"https://github.com/Microsoft/TypeScript/pull/27028#issuecomment-429334450\">another caveat</a> of this new functionality is that due to certain limitations, <code>bind</code>, <code>call</code>, and <code>apply</code> can’t yet fully model generic functions or functions that have overloads.\nWhen using these methods on a generic function, type parameters will be substituted with the empty object type (<code>{}</code>), and when used on a function with overloads, only the last overload will ever be modeled.</p>\n<h2 id=\"generic-spread-expressions-in-object-literals\" style=\"position:relative;\"><a href=\"#generic-spread-expressions-in-object-literals\" aria-label=\"generic spread expressions in object literals permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Generic spread expressions in object literals</h2>\n<p>In TypeScript 3.2, object literals now allow generic spread expressions which now produce intersection types, similar to the <code>Object.assign</code> function and JSX literals. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> taggedObject&lt;T, U </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> string&gt;(obj: T, tag: U) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> { ...obj, tag }; </span><span style=\"color: #008000\">// T & { tag: U }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = taggedObject({ x: </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">, y: </span><span style=\"color: #09835A\">20</span><span style=\"color: #000000\"> }, </span><span style=\"color: #A31515\">\"point\"</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// { x: number, y: number } & { tag: \"point\" }</span></code></div></pre>\n<p>Property assignments and non-generic spread expressions are merged to the greatest extent possible on either side of a generic spread expression. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> foo1&lt;T&gt;(t: T, obj1: { a: string }, obj2: { b: string }) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> { ...obj1, x: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, ...t, ...obj2, y: </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\"> }; </span><span style=\"color: #008000\">// { a: string, x: number } & T & { b: string, y: number }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Non-generic spread expressions continue to be processed as before: Call and construct signatures are stripped, only non-method properties are preserved, and for properties with the same name, the type of the rightmost property is used. This contrasts with intersection types which concatenate call and construct signatures, preserve all properties, and intersect the types of properties with the same name. Thus, spreads of the same types may produce different results when they are created through instantiation of generic types:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> spread&lt;T, U&gt;(t: T, u: U) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> { ...t, ...u }; </span><span style=\"color: #008000\">// T & U</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: { a: string; b: number };</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> y: { b: string; c: boolean };</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> s1 = { ...x, ...y }; </span><span style=\"color: #008000\">// { a: string, b: string, c: boolean }</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> s2 = spread(x, y); </span><span style=\"color: #008000\">// { a: string, b: number } & { b: string, c: boolean }</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> b1 = s1.b; </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> b2 = s2.b; </span><span style=\"color: #008000\">// number & string</span></code></div></pre>\n<h2 id=\"generic-object-rest-variables-and-parameters\" style=\"position:relative;\"><a href=\"#generic-object-rest-variables-and-parameters\" aria-label=\"generic object rest variables and parameters permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Generic object rest variables and parameters</h2>\n<p>TypeScript 3.2 also allows destructuring a rest binding from a generic variable. This is achieved by using the predefined <code>Pick</code> and <code>Exclude</code> helper types from <code>lib.d.ts</code>, and using the generic type in question as well as the names of the other bindings in the destructuring pattern.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> excludeTag&lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> { tag: string }&gt;(obj: T) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> { tag, ...rest } = obj;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> rest; </span><span style=\"color: #008000\">// Pick&lt;T, Exclude&lt;keyof T, \"tag\"&gt;&gt;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> taggedPoint = { x: </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">, y: </span><span style=\"color: #09835A\">20</span><span style=\"color: #000000\">, tag: </span><span style=\"color: #A31515\">\"point\"</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> point = excludeTag(taggedPoint); </span><span style=\"color: #008000\">// { x: number, y: number }</span></code></div></pre>\n<h2 id=\"bigint\" style=\"position:relative;\"><a href=\"#bigint\" aria-label=\"bigint permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>BigInt</h2>\n<p>BigInts are part of an upcoming proposal in ECMAScript that allow us to model theoretically arbitrarily large integers.\nTypeScript 3.2 brings type-checking for BigInts, as well as support for emitting BigInt literals when targeting <code>esnext</code>.</p>\n<p>BigInt support in TypeScript introduces a new primitive type called the <code>bigint</code> (all lowercase).\nYou can get a <code>bigint</code> by calling the <code>BigInt()</code> function or by writing out a BigInt literal by adding an <code>n</code> to the end of any integer numeric literal:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> foo: bigint = BigInt(</span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// the BigInt function</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> bar: bigint = 100n; </span><span style=\"color: #008000\">// a BigInt literal</span>\n\n<span style=\"color: #008000\">// *Slaps roof of fibonacci function*</span>\n<span style=\"color: #008000\">// This bad boy returns ints that can get *so* big!</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> fibonacci(n: bigint) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> result = 1n;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> last = 0n, i = 0n; i &lt; n; i++) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> current = result;</span>\n<span style=\"color: #000000\">    result += last;</span>\n<span style=\"color: #000000\">    last = current;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> result;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #000000\">fibonacci(10000n);</span></code></div></pre>\n<p>While you might imagine close interaction between <code>number</code> and <code>bigint</code>, the two are separate domains.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> foo: number;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> bar: bigint;</span>\n\n<span style=\"color: #000000\">foo = bar; </span><span style=\"color: #008000\">// error: Type 'bigint' is not assignable to type 'number'.</span>\n<span style=\"color: #000000\">bar = foo; </span><span style=\"color: #008000\">// error: Type 'number' is not assignable to type 'bigint'.</span></code></div></pre>\n<p>As specified in ECMAScript, mixing <code>number</code>s and <code>bigint</code>s in arithmetic operations is an error.\nYou’ll have to explicitly convert values to <code>BigInt</code>s.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #000000\">console.log(</span><span style=\"color: #09835A\">3.141592</span><span style=\"color: #000000\"> * 10000n); </span><span style=\"color: #008000\">// error</span>\n<span style=\"color: #000000\">console.log(</span><span style=\"color: #09835A\">3145</span><span style=\"color: #000000\"> * 10n); </span><span style=\"color: #008000\">// error</span>\n<span style=\"color: #000000\">console.log(BigInt(</span><span style=\"color: #09835A\">3145</span><span style=\"color: #000000\">) * 10n); </span><span style=\"color: #008000\">// okay!</span></code></div></pre>\n<p>Also important to note is that <code>bigint</code>s produce a new string when using the <code>typeof</code> operator: the string <code>\"bigint\"</code>.\nThus, TypeScript correctly narrows using <code>typeof</code> as you’d expect.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> whatKindOfNumberIsIt(x: number | bigint) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> x === </span><span style=\"color: #A31515\">\"bigint\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    console.log(</span><span style=\"color: #A31515\">\"'x' is a bigint!\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  } </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    console.log(</span><span style=\"color: #A31515\">\"'x' is a floating-point number\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>We’d like to extend a huge thanks to <a href=\"https://github.com/calebsander\">Caleb Sander</a> for all the work on this feature.\nWe’re grateful for the contribution, and we’re sure our users are too!</p>\n<h3 id=\"caveats-4\" style=\"position:relative;\"><a href=\"#caveats-4\" aria-label=\"caveats 4 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Caveats</h3>\n<p>As we mentioned, BigInt support is only available for the <code>esnext</code> target.\nIt may not be obvious, but because BigInts have different behavior for mathematical operators like <code>+</code>, <code>-</code>, <code>*</code>, etc., providing functionality for older targets where the feature doesn’t exist (like <code>es2017</code> and below) would involve rewriting each of these operations.\nTypeScript would need to dispatch to the correct behavior depending on the type, and so every addition, string concatenation, multiplication, etc. would involve a function call.</p>\n<p>For that reason, we have no immediate plans to provide downleveling support.\nOn the bright side, Node 11 and newer versions of Chrome already support this feature, so you’ll be able to use BigInts there when targeting <code>esnext</code>.</p>\n<p>Certain targets may include a polyfill or BigInt-like runtime object.\nFor those purposes you may want to add <code>esnext.bigint</code> to the <code>lib</code> setting in your compiler options.</p>\n<h2 id=\"non-unit-types-as-union-discriminants\" style=\"position:relative;\"><a href=\"#non-unit-types-as-union-discriminants\" aria-label=\"non unit types as union discriminants permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Non-unit types as union discriminants</h2>\n<p>TypeScript 3.2 makes narrowing easier by relaxing rules for what it considers a discriminant property.\nCommon properties of unions are now considered discriminants as long as they contain <em>some</em> singleton type (e.g. a string literal, <code>null</code>, or <code>undefined</code>), and they contain no generics.</p>\n<p>As a result, TypeScript 3.2 considers the <code>error</code> property in the following example to be a discriminant, whereas before it wouldn’t since <code>Error</code> isn’t a singleton type.\nThanks to this, narrowing works correctly in the body of the <code>unwrap</code> function.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Result&lt;T&gt; = { error: Error; data: null } | { error: null; data: T };</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> unwrap&lt;T&gt;(result: Result&lt;T&gt;) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (result.error) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// Here 'error' is non-null</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">throw</span><span style=\"color: #000000\"> result.error;</span>\n<span style=\"color: #000000\">  }</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Now 'data' is non-null</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> result.data;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"tsconfigjson-inheritance-via-nodejs-packages\" style=\"position:relative;\"><a href=\"#tsconfigjson-inheritance-via-nodejs-packages\" aria-label=\"tsconfigjson inheritance via nodejs packages permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>tsconfig.json</code> inheritance via Node.js packages</h2>\n<p>TypeScript 3.2 now resolves <code>tsconfig.json</code>s from <code>node_modules</code>. When using a bare path for the <code>\"extends\"</code> field in <code>tsconfig.json</code>, TypeScript will dive into <code>node_modules</code> packages for us.</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"extends\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"@my-team/tsconfig-base\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"include\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"./**/*\"</span><span style=\"color: #000000\">]</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #A31515\">\"compilerOptions\"</span><span style=\"color: #CD3131\">:</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #008000\">// Override certain options on a project-by-project basis.</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0451A5\">\"strictBindCallApply\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Here, TypeScript will climb up <code>node_modules</code> folders looking for a <code>@my-team/tsconfig-base</code> package. For each of those packages, TypeScript will first check whether <code>package.json</code> contains a <code>\"tsconfig\"</code> field, and if it does, TypeScript will try to load a configuration file from that field. If neither exists, TypeScript will try to read from a <code>tsconfig.json</code> at the root. This is similar to the lookup process for <code>.js</code> files in packages that Node uses, and the <code>.d.ts</code> lookup process that TypeScript already uses.</p>\n<p>This feature can be extremely useful for bigger organizations, or projects with lots of distributed dependencies.</p>\n<h2 id=\"the-new---showconfig-flag\" style=\"position:relative;\"><a href=\"#the-new---showconfig-flag\" aria-label=\"the new   showconfig flag permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The new <code>--showConfig</code> flag</h2>\n<p><code>tsc</code>, the TypeScript compiler, supports a new flag called <code>--showConfig</code>.\nWhen running <code>tsc --showConfig</code>, TypeScript will calculate the effective <code>tsconfig.json</code> (after calculating options inherited from the <code>extends</code> field) and print that out.\nThis can be useful for diagnosing configuration issues in general.</p>\n<h2 id=\"objectdefineproperty-declarations-in-javascript\" style=\"position:relative;\"><a href=\"#objectdefineproperty-declarations-in-javascript\" aria-label=\"objectdefineproperty declarations in javascript permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>Object.defineProperty</code> declarations in JavaScript</h2>\n<p>When writing in JavaScript files (using <code>allowJs</code>), TypeScript now recognizes declarations that use <code>Object.defineProperty</code>.\nThis means you’ll get better completions, and stronger type-checking when enabling type-checking in JavaScript files (by turning on the <code>checkJs</code> option or adding a <code>// @ts-check</code> comment to the top of your file).</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #008000\">// @ts-check</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> obj = {};</span>\n<span style=\"color: #000000\">Object.defineProperty(obj, </span><span style=\"color: #A31515\">\"x\"</span><span style=\"color: #000000\">, { value: </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, writable: </span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\"> });</span>\n\n<span style=\"color: #000000\">obj.x.toLowercase();</span>\n<span style=\"color: #008000\">//    ~~~~~~~~~~~</span>\n<span style=\"color: #008000\">//    error:</span>\n<span style=\"color: #008000\">//     Property 'toLowercase' does not exist on type 'string'.</span>\n<span style=\"color: #008000\">//     Did you mean 'toLowerCase'?</span>\n\n<span style=\"color: #000000\">obj.x = </span><span style=\"color: #A31515\">\"world\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #008000\">//  ~</span>\n<span style=\"color: #008000\">//  error:</span>\n<span style=\"color: #008000\">//   Cannot assign to 'x' because it is a read-only property.</span></code></div></pre>\n<h2 id=\"typescript-31\" style=\"position:relative;\"><a href=\"#typescript-31\" aria-label=\"typescript 31 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 3.1</h2>\n<h2 id=\"mapped-types-on-tuples-and-arrays\" style=\"position:relative;\"><a href=\"#mapped-types-on-tuples-and-arrays\" aria-label=\"mapped types on tuples and arrays permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Mapped types on tuples and arrays</h2>\n<p>In TypeScript 3.1, mapped object types<sup><a href=\"#ts-3-1-only-homomorphic\">[1]</a></sup> over tuples and arrays now produce new tuples/arrays, rather than creating a new type where members like <code>push()</code>, <code>pop()</code>, and <code>length</code> are converted.\nFor example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> MapToPromise&lt;T&gt; = { [K </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> keyof T]: Promise&lt;T[K]&gt; };</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Coordinate = [number, number];</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> PromiseCoordinate = MapToPromise&lt;Coordinate&gt;; </span><span style=\"color: #008000\">// [Promise&lt;number&gt;, Promise&lt;number&gt;]</span></code></div></pre>\n<p><code>MapToPromise</code> takes a type <code>T</code>, and when that type is a tuple like <code>Coordinate</code>, only the numeric properties are converted.\nIn <code>[number, number]</code>, there are two numerically named properties: <code>0</code> and <code>1</code>.\nWhen given a tuple like that, <code>MapToPromise</code> will create a new tuple where the <code>0</code> and <code>1</code> properties are <code>Promise</code>s of the original type.\nSo the resulting type <code>PromiseCoordinate</code> ends up with the type <code>[Promise&#x3C;number>, Promise&#x3C;number>]</code>.</p>\n<h2 id=\"properties-declarations-on-functions\" style=\"position:relative;\"><a href=\"#properties-declarations-on-functions\" aria-label=\"properties declarations on functions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Properties declarations on functions</h2>\n<p>TypeScript 3.1 brings the ability to define properties on function declarations and <code>const</code>-declared functons, simply by assigning to properties on these functions in the same scope.\nThis allows us to write canonical JavaScript code without resorting to <code>namespace</code> hacks.\nFor example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> readImage(path: string, callback: (err: any, image: Image) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// ...</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #000000\">readImage.sync = (path: string) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> contents = fs.readFileSync(path);</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> decodeImageSync(contents);</span>\n<span style=\"color: #000000\">};</span></code></div></pre>\n<p>Here, we have a function <code>readImage</code> which reads an image in a non-blocking asynchronous way.\nIn addition to <code>readImage</code>, we’ve provided a convenience function on <code>readImage</code> itself called <code>readImage.sync</code>.</p>\n<p>While ECMAScript exports are often a better way of providing this functionality, this new support allows code written in this style to “just work” TypeScript.\nAdditionaly, this approach for property declarations allows us to express common patterns like <code>defaultProps</code> and <code>propTypes</code> on React stateless function components (SFCs).</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> FooComponent = ({ name }) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> &lt;div&gt;Hello! I am {name}&lt;/div&gt;;</span>\n\n<span style=\"color: #000000\">FooComponent.defaultProps = {</span>\n<span style=\"color: #000000\">  name: </span><span style=\"color: #A31515\">\"(anonymous)\"</span>\n<span style=\"color: #000000\">};</span></code></div></pre>\n<!--\nfs.readFile(path, (err, data) => {\n        if (err) callback(err, undefined);\n        else decodeImage(data, (err, image) => {\n            if (err) callback(err, undefined);\n            else callback(undefined, image);\n        });\n    });\n-->\n<hr>\n<p><sup id=\"ts-3-1-only-homomorphic\">[1]</sup> More specifically, homomorphic mapped types like in the above form.</p>\n<h2 id=\"version-selection-with-typesversions\" style=\"position:relative;\"><a href=\"#version-selection-with-typesversions\" aria-label=\"version selection with typesversions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Version selection with <code>typesVersions</code></h2>\n<p>Feedback from our community, as well as our own experience, has shown us that leveraging the newest TypeScript features while also accomodating users on the older versions are difficult.\nTypeScript introduces a new feature called <code>typesVersions</code> to help accomodate these scenarios.</p>\n<p>When using Node module resolution in TypeScript 3.1, when TypeScript cracks open a <code>package.json</code> file to figure out which files it needs to read, it first looks at a new field called <code>typesVersions</code>.\nA <code>package.json</code> with a <code>typesVersions</code> field might look like this:</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"name\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"package-name\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"version\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"1.0\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"types\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./index.d.ts\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"typesVersions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"&gt;=3.1\"</span><span style=\"color: #000000\">: { </span><span style=\"color: #0451A5\">\"*\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"ts3.1/*\"</span><span style=\"color: #000000\">] }</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>This <code>package.json</code> tells TypeScript to check whether the current version of TypeScript is running.\nIf it’s 3.1 or later, it figures out the path you’ve imported relative to the package, and reads from the package’s <code>ts3.1</code> folder.\nThat’s what that <code>{ \"*\": [\"ts3.1/*\"] }</code> means - if you’re familiar with path mapping today, it works exactly like that.</p>\n<p>So in the above example, if we’re importing from <code>\"package-name\"</code>, we’ll try to resolve from <code>[...]/node_modules/package-name/ts3.1/index.d.ts</code> (and other relevant paths) when running in TypeScript 3.1.\nIf we import from <code>package-name/foo</code>, we’ll try to look for <code>[...]/node_modules/package-name/ts3.1/foo.d.ts</code> and <code>[...]/node_modules/package-name/ts3.1/foo/index.d.ts</code>.</p>\n<p>What if we’re not running in TypeScript 3.1 in this example?\nWell, if none of the fields in <code>typesVersions</code> get matched, TypeScript falls back to the <code>types</code> field, so here TypeScript 3.0 and earlier will be redirected to <code>[...]/node_modules/package-name/index.d.ts</code>.</p>\n<h3 id=\"matching-behavior\" style=\"position:relative;\"><a href=\"#matching-behavior\" aria-label=\"matching behavior permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Matching behavior</h3>\n<p>The way that TypeScript decides on whether a version of the compiler &#x26; language matches is by using Node’s <a href=\"https://github.com/npm/node-semver#ranges\">semver ranges</a>.</p>\n<h3 id=\"multiple-fields\" style=\"position:relative;\"><a href=\"#multiple-fields\" aria-label=\"multiple fields permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Multiple fields</h3>\n<p><code>typesVersions</code> can support multiple fields where each field name is specified by the range to match on.</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"name\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"package-name\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"version\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"1.0\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"types\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./index.d.ts\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"typesVersions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"&gt;=3.2\"</span><span style=\"color: #000000\">: { </span><span style=\"color: #0451A5\">\"*\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"ts3.2/*\"</span><span style=\"color: #000000\">] },</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"&gt;=3.1\"</span><span style=\"color: #000000\">: { </span><span style=\"color: #0451A5\">\"*\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"ts3.1/*\"</span><span style=\"color: #000000\">] }</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Since ranges have the potential to overlap, determining which redirect applies is order-specific.\nThat means in the above example, even though both the <code>>=3.2</code> and the <code>>=3.1</code> matchers support TypeScript 3.2 and above, reversing the order could have different behavior, so the above sample would not be equivalent to the following.</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #CD3131\">name</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"package-name\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #CD3131\">version</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"1.0\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #CD3131\">types</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./index.d.ts\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #CD3131\">typesVersions</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// NOTE: this doesn't work!</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"&gt;=3.1\"</span><span style=\"color: #000000\">: { </span><span style=\"color: #0451A5\">\"*\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"ts3.1/*\"</span><span style=\"color: #000000\">] },</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"&gt;=3.2\"</span><span style=\"color: #000000\">: { </span><span style=\"color: #0451A5\">\"*\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"ts3.2/*\"</span><span style=\"color: #000000\">] }</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"typescript-30\" style=\"position:relative;\"><a href=\"#typescript-30\" aria-label=\"typescript 30 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 3.0</h2>\n<h2 id=\"tuples-in-rest-parameters-and-spread-expressions\" style=\"position:relative;\"><a href=\"#tuples-in-rest-parameters-and-spread-expressions\" aria-label=\"tuples in rest parameters and spread expressions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Tuples in rest parameters and spread expressions</h2>\n<p>TypeScript 3.0 adds support to multiple new capabilities to interact with function parameter lists as tuple types.\nTypeScript 3.0 adds support for:</p>\n<ul>\n<li><a href=\"#rest-parameters-with-tuple-types\">Expansion of rest parameters with tuple types into discrete parameters.</a></li>\n<li><a href=\"#spread-expressions-with-tuple-types\">Expansion of spread expressions with tuple types into discrete arguments.</a></li>\n<li><a href=\"#generic-rest-parameters\">Generic rest parameters and corresponding inference of tuple types.</a></li>\n<li><a href=\"#optional-elements-in-tuple-types\">Optional elements in tuple types.</a></li>\n<li><a href=\"#rest-elements-in-tuple-types\">Rest elements in tuple types.</a></li>\n</ul>\n<p>With these features it becomes possible to strongly type a number of higher-order functions that transform functions and their parameter lists.</p>\n<h3 id=\"rest-parameters-with-tuple-types\" style=\"position:relative;\"><a href=\"#rest-parameters-with-tuple-types\" aria-label=\"rest parameters with tuple types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Rest parameters with tuple types</h3>\n<p>When a rest parameter has a tuple type, the tuple type is expanded into a sequence of discrete parameters.\nFor example the following two declarations are equivalent:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> foo(...args: [number, string, boolean]): void;</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> foo(args_0: number, args_1: string, args_2: boolean): void;</span></code></div></pre>\n<h3 id=\"spread-expressions-with-tuple-types\" style=\"position:relative;\"><a href=\"#spread-expressions-with-tuple-types\" aria-label=\"spread expressions with tuple types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Spread expressions with tuple types</h3>\n<p>When a function call includes a spread expression of a tuple type as the last argument, the spread expression corresponds to a sequence of discrete arguments of the tuple element types.</p>\n<p>Thus, the following calls are equivalent:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> args: [number, string, boolean] = [</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">];</span>\n<span style=\"color: #000000\">foo(</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">foo(args[</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">], args[</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">], args[</span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">]);</span>\n<span style=\"color: #000000\">foo(...args);</span></code></div></pre>\n<h3 id=\"generic-rest-parameters\" style=\"position:relative;\"><a href=\"#generic-rest-parameters\" aria-label=\"generic rest parameters permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Generic rest parameters</h3>\n<p>A rest parameter is permitted to have a generic type that is constrained to an array type, and type inference can infer tuple types for such generic rest parameters. This enables higher-order capturing and spreading of partial parameter lists:</p>\n<h5 id=\"example\" style=\"position:relative;\"><a href=\"#example\" aria-label=\"example permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> bind&lt;T, U </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> any[], V&gt;(</span>\n<span style=\"color: #000000\">  f: (x: T, ...args: U) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> V,</span>\n<span style=\"color: #000000\">  x: T</span>\n<span style=\"color: #000000\">): (...args: U) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> V;</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f3(x: number, y: string, z: boolean): void;</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> f2 = bind(f3, </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// (y: string, z: boolean) =&gt; void</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> f1 = bind(f2, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// (z: boolean) =&gt; void</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> f0 = bind(f1, </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// () =&gt; void</span>\n\n<span style=\"color: #000000\">f3(</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">f2(</span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">f1(</span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">f0();</span></code></div></pre>\n<p>In the declaration of <code>f2</code> above, type inference infers types <code>number</code>, <code>[string, boolean]</code> and <code>void</code> for <code>T</code>, <code>U</code> and <code>V</code> respectively.</p>\n<p>Note that when a tuple type is inferred from a sequence of parameters and later expanded into a parameter list, as is the case for <code>U</code>, the original parameter names are used in the expansion (however, the names have no semantic meaning and are not otherwise observable).</p>\n<h3 id=\"optional-elements-in-tuple-types\" style=\"position:relative;\"><a href=\"#optional-elements-in-tuple-types\" aria-label=\"optional elements in tuple types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Optional elements in tuple types</h3>\n<p>Tuple types now permit a <code>?</code> postfix on element types to indicate that the element is optional:</p>\n<h5 id=\"example-1\" style=\"position:relative;\"><a href=\"#example-1\" aria-label=\"example 1 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> t: [number, string?, boolean?];</span>\n<span style=\"color: #000000\">t = [</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">];</span>\n<span style=\"color: #000000\">t = [</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">];</span>\n<span style=\"color: #000000\">t = [</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">];</span></code></div></pre>\n<p>In <code>--strictNullChecks</code> mode, a <code>?</code> modifier automatically includes <code>undefined</code> in the element type, similar to optional parameters.</p>\n<p>A tuple type permits an element to be omitted if it has a postfix <code>?</code> modifier on its type and all elements to the right of it also have <code>?</code> modifiers.</p>\n<p>When tuple types are inferred for rest parameters, optional parameters in the source become optional tuple elements in the inferred type.</p>\n<p>The <code>length</code> property of a tuple type with optional elements is a union of numeric literal types representing the possible lengths.\nFor example, the type of the <code>length</code> property in the tuple type <code>[number, string?, boolean?]</code> is <code>1 | 2 | 3</code>.</p>\n<h3 id=\"rest-elements-in-tuple-types\" style=\"position:relative;\"><a href=\"#rest-elements-in-tuple-types\" aria-label=\"rest elements in tuple types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Rest elements in tuple types</h3>\n<p>The last element of a tuple type can be a rest element of the form <code>...X</code>, where <code>X</code> is an array type.\nA rest element indicates that the tuple type is open-ended and may have zero or more additional elements of the array element type.\nFor example, <code>[number, ...string[]]</code> means tuples with a <code>number</code> element followed by any number of <code>string</code> elements.</p>\n<h5 id=\"example-2\" style=\"position:relative;\"><a href=\"#example-2\" aria-label=\"example 2 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> tuple&lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> any[]&gt;(...args: T): T {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> args;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> numbers: number[] = getArrayOfNumbers();</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> t1 = tuple(</span><span style=\"color: #A31515\">\"foo\"</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// [string, number, boolean]</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> t2 = tuple(</span><span style=\"color: #A31515\">\"bar\"</span><span style=\"color: #000000\">, ...numbers); </span><span style=\"color: #008000\">// [string, ...number[]]</span></code></div></pre>\n<p>The type of the <code>length</code> property of a tuple type with a rest element is <code>number</code>.</p>\n<h2 id=\"new-unknown-top-type\" style=\"position:relative;\"><a href=\"#new-unknown-top-type\" aria-label=\"new unknown top type permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New <code>unknown</code> top type</h2>\n<p>TypeScript 3.0 introduces a new top type <code>unknown</code>.\n<code>unknown</code> is the type-safe counterpart of <code>any</code>.\nAnything is assignable to <code>unknown</code>, but <code>unknown</code> isn’t assignable to anything but itself and <code>any</code> without a type assertion or a control flow based narrowing.\nLikewise, no operations are permitted on an <code>unknown</code> without first asserting or narrowing to a more specific type.</p>\n<h5 id=\"example-3\" style=\"position:relative;\"><a href=\"#example-3\" aria-label=\"example 3 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// In an intersection everything absorbs unknown</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T00 = unknown & null; </span><span style=\"color: #008000\">// null</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T01 = unknown & undefined; </span><span style=\"color: #008000\">// undefined</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T02 = unknown & null & undefined; </span><span style=\"color: #008000\">// null & undefined (which becomes never)</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T03 = unknown & string; </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T04 = unknown & string[]; </span><span style=\"color: #008000\">// string[]</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T05 = unknown & unknown; </span><span style=\"color: #008000\">// unknown</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T06 = unknown & any; </span><span style=\"color: #008000\">// any</span>\n\n<span style=\"color: #008000\">// In a union an unknown absorbs everything</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T10 = unknown | null; </span><span style=\"color: #008000\">// unknown</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T11 = unknown | undefined; </span><span style=\"color: #008000\">// unknown</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T12 = unknown | null | undefined; </span><span style=\"color: #008000\">// unknown</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T13 = unknown | string; </span><span style=\"color: #008000\">// unknown</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T14 = unknown | string[]; </span><span style=\"color: #008000\">// unknown</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T15 = unknown | unknown; </span><span style=\"color: #008000\">// unknown</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T16 = unknown | any; </span><span style=\"color: #008000\">// any</span>\n\n<span style=\"color: #008000\">// Type variable and unknown in union and intersection</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T20&lt;T&gt; = T & {}; </span><span style=\"color: #008000\">// T & {}</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T21&lt;T&gt; = T | {}; </span><span style=\"color: #008000\">// T | {}</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T22&lt;T&gt; = T & unknown; </span><span style=\"color: #008000\">// T</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T23&lt;T&gt; = T | unknown; </span><span style=\"color: #008000\">// unknown</span>\n\n<span style=\"color: #008000\">// unknown in conditional types</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T30&lt;T&gt; = unknown extends T ? true : false; </span><span style=\"color: #008000\">// Deferred</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T31&lt;T&gt; = T extends unknown ? true : false; </span><span style=\"color: #008000\">// Deferred (so it distributes)</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T32&lt;T&gt; = never extends T ? true : false; </span><span style=\"color: #008000\">// true</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T33&lt;T&gt; = T extends never ? true : false; </span><span style=\"color: #008000\">// Deferred</span>\n\n<span style=\"color: #008000\">// keyof unknown</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T40 = </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> any; </span><span style=\"color: #008000\">// string | number | symbol</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T41 = </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> unknown; </span><span style=\"color: #008000\">// never</span>\n\n<span style=\"color: #008000\">// Only equality operators are allowed with unknown</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f10(x: unknown) {</span>\n<span style=\"color: #000000\">  x == </span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  x !== </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  x &gt;= </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">  x + </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">  x * </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">  -x; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">  +x; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// No property accesses, element accesses, or function calls</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f11(x: unknown) {</span>\n<span style=\"color: #000000\">  x.foo; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">  x[</span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">]; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">  x(); </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> x(); </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// typeof, instanceof, and user defined type predicates</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> isFunction(x: unknown): x </span><span style=\"color: #0000FF\">is</span><span style=\"color: #000000\"> Function;</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f20(x: unknown) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> x === </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\"> || </span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> x === </span><span style=\"color: #A31515\">\"number\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    x; </span><span style=\"color: #008000\">// string | number</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (x </span><span style=\"color: #0000FF\">instanceof</span><span style=\"color: #000000\"> Error) {</span>\n<span style=\"color: #000000\">    x; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (isFunction(x)) {</span>\n<span style=\"color: #000000\">    x; </span><span style=\"color: #008000\">// Function</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Homomorphic mapped type over unknown</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T50&lt;T&gt; = { [P </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> keyof T]: number };</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T51 = T50&lt;any&gt;; </span><span style=\"color: #008000\">// { [x: string]: number }</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T52 = T50&lt;unknown&gt;; </span><span style=\"color: #008000\">// {}</span>\n\n<span style=\"color: #008000\">// Anything is assignable to unknown</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f21&lt;T&gt;(pAny: any, pNever: never, pT: T) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: unknown;</span>\n<span style=\"color: #000000\">  x = </span><span style=\"color: #09835A\">123</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  x = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  x = [</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">];</span>\n<span style=\"color: #000000\">  x = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Error();</span>\n<span style=\"color: #000000\">  x = x;</span>\n<span style=\"color: #000000\">  x = pAny;</span>\n<span style=\"color: #000000\">  x = pNever;</span>\n<span style=\"color: #000000\">  x = pT;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// unknown assignable only to itself and any</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f22(x: unknown) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v1: any = x;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v2: unknown = x;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v3: object = x; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v4: string = x; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v5: string[] = x; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v6: {} = x; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v7: {} | null | undefined = x; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Type parameter 'T extends unknown' not related to object</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f23&lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> unknown&gt;(x: T) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> y: object = x; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Anything but primitive assignable to { [x: string]: unknown }</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f24(x: { [x: string]: unknown }) {</span>\n<span style=\"color: #000000\">  x = {};</span>\n<span style=\"color: #000000\">  x = { a: </span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #000000\">  x = [</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">];</span>\n<span style=\"color: #000000\">  x = </span><span style=\"color: #09835A\">123</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Locals of type unknown always considered initialized</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f25() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: unknown;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> y = x;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Spread of unknown causes result to be unknown</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f26(x: {}, y: unknown, z: any) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> o1 = { a: </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, ...x }; </span><span style=\"color: #008000\">// { a: number }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> o2 = { a: </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, ...x, ...y }; </span><span style=\"color: #008000\">// unknown</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> o3 = { a: </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, ...x, ...y, ...z }; </span><span style=\"color: #008000\">// any</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Functions with unknown return type don't need return expressions</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f27(): unknown {}</span>\n\n<span style=\"color: #008000\">// Rest type cannot be created from unknown</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f28(x: unknown) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> { ...a } = x; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Class properties of type unknown don't need definite assignment</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C1 {</span>\n<span style=\"color: #000000\">  a: string; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">  b: unknown;</span>\n<span style=\"color: #000000\">  c: any;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"support-for-defaultprops-in-jsx\" style=\"position:relative;\"><a href=\"#support-for-defaultprops-in-jsx\" aria-label=\"support for defaultprops in jsx permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for <code>defaultProps</code> in JSX</h2>\n<p>TypeScript 2.9 and earlier didn’t leverage <a href=\"https://reactjs.org/docs/typechecking-with-proptypes.html#default-prop-values\">React <code>defaultProps</code></a> declarations inside JSX components.\nUsers would often have to declare properties optional and use non-null assertions inside of <code>render</code>, or they’d use type-assertions to fix up the type of the component before exporting it.</p>\n<p>TypeScript 3.0 adds supports a new type alias in the <code>JSX</code> namespace called <code>LibraryManagedAttributes</code>.\nThis helper type defines a transformation on the component’s <code>Props</code> type, before using to check a JSX expression targeting it; thus allowing customization like: how conflicts between provided props and inferred props are handled, how inferences are mapped, how optionality is handled, and how inferences from differing places should be combined.</p>\n<p>In short using this general type, we can model React’s specific behavior for things like <code>defaultProps</code> and, to some extent, <code>propTypes</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">tsx</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Props {</span>\n<span style=\"color: #000000\">  name: string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Greet </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> React.Component&lt;Props&gt; {</span>\n<span style=\"color: #000000\">  render() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> { name } = </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.props;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #800000\">&lt;div&gt;</span><span style=\"color: #000000\">Hello ${name.toUpperCase()}!</span><span style=\"color: #800000\">&lt;/div&gt;</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">static</span><span style=\"color: #000000\"> defaultProps = { name: </span><span style=\"color: #A31515\">\"world\"</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Type-checks! No type assertions needed!</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> el = </span><span style=\"color: #800000\">&lt;Greet</span><span style=\"color: #000000\"> </span><span style=\"color: #800000\">/&gt;</span><span style=\"color: #000000\">;</span></code></div></pre>\n<h3 id=\"caveats-5\" style=\"position:relative;\"><a href=\"#caveats-5\" aria-label=\"caveats 5 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Caveats</h3>\n<h4 id=\"explicit-types-on-defaultprops\" style=\"position:relative;\"><a href=\"#explicit-types-on-defaultprops\" aria-label=\"explicit types on defaultprops permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Explicit types on <code>defaultProps</code></h4>\n<p>The default-ed properties are inferred from the <code>defaultProps</code> property type. If an explicit type annotation is added, e.g. <code>static defaultProps: Partial&#x3C;Props>;</code> the compiler will not be able to identify which properties have defaults (since the type of <code>defaultProps</code> include all properties of <code>Props</code>).</p>\n<p>Use <code>static defaultProps: Pick&#x3C;Props, \"name\">;</code> as an explicit type annotation instead, or do not add a type annotation as done in the example above.</p>\n<p>For stateless function components (SFCs) use ES2015 default initializers for SFCs:</p>\n<pre class=\"shiki\"><div class=\"language-id\">tsx</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> Greet({ name = </span><span style=\"color: #A31515\">\"world\"</span><span style=\"color: #000000\"> }: Props) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #800000\">&lt;div&gt;</span><span style=\"color: #000000\">Hello ${name.toUpperCase()}!</span><span style=\"color: #800000\">&lt;/div&gt;</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h5 id=\"changes-to-typesreact\" style=\"position:relative;\"><a href=\"#changes-to-typesreact\" aria-label=\"changes to typesreact permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Changes to <code>@types/React</code></h5>\n<p>Corresponding changes to add <code>LibraryManagedAttributes</code> definition to the <code>JSX</code> namespace in <code>@types/React</code> are still needed.\nKeep in mind that there are some limitations.</p>\n<h2 id=\"-reference-lib--reference-directives\" style=\"position:relative;\"><a href=\"#-reference-lib--reference-directives\" aria-label=\" reference lib  reference directives permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>/// &#x3C;reference lib=\"...\" /></code> reference directives</h2>\n<p>TypeScript adds a new triple-slash-reference directive (<code>/// &#x3C;reference lib=\"name\" /></code>), allowing a file to explicitly include an existing built-in <em>lib</em> file.</p>\n<p>Built-in <em>lib</em> files are referenced in the same fashion as the <code>\"lib\"</code> compiler option in <em>tsconfig.json</em> (e.g. use <code>lib=\"es2015\"</code> and not <code>lib=\"lib.es2015.d.ts\"</code>, etc.).</p>\n<p>For declaration file authors who rely on built-in types, e.g. DOM APIs or built-in JS run-time constructors like <code>Symbol</code> or <code>Iterable</code>, triple-slash-reference lib directives are the recommended. Previously these .d.ts files had to add forward/duplicate declarations of such types.</p>\n<h5 id=\"example-4\" style=\"position:relative;\"><a href=\"#example-4\" aria-label=\"example 4 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<p>Using <code>/// &#x3C;reference lib=\"es2017.string\" /></code> to one of the files in a compilation is equivalent to compiling with <code>--lib es2017.string</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">/// &lt;reference lib=\"es2017.string\" /&gt;</span>\n\n<span style=\"color: #A31515\">\"foo\"</span><span style=\"color: #000000\">.padStart(</span><span style=\"color: #09835A\">4</span><span style=\"color: #000000\">);</span></code></div></pre>\n<h2 id=\"typescript-29\" style=\"position:relative;\"><a href=\"#typescript-29\" aria-label=\"typescript 29 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 2.9</h2>\n<h2 id=\"support-number-and-symbol-named-properties-with-keyof-and-mapped-types\" style=\"position:relative;\"><a href=\"#support-number-and-symbol-named-properties-with-keyof-and-mapped-types\" aria-label=\"support number and symbol named properties with keyof and mapped types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support <code>number</code> and <code>symbol</code> named properties with <code>keyof</code> and mapped types</h2>\n<p>TypeScript 2.9 adds support for <code>number</code> and <code>symbol</code> named properties in index types and mapped types.\nPreviously, the <code>keyof</code> operator and mapped types only supported <code>string</code> named properties.</p>\n<p>Changes include:</p>\n<ul>\n<li>An index type <code>keyof T</code> for some type <code>T</code> is a subtype of <code>string | number | symbol</code>.</li>\n<li>A mapped type <code>{ [P in K]: XXX }</code> permits any <code>K</code> assignable to <code>string | number | symbol</code>.</li>\n<li>In a <code>for...in</code> statement for an object of a generic type <code>T</code>, the inferred type of the iteration variable was previously <code>keyof T</code> but is now <code>Extract&#x3C;keyof T, string></code>. (In other words, the subset of <code>keyof T</code> that includes only string-like values.)</li>\n</ul>\n<p>Given an object type <code>X</code>, <code>keyof X</code> is resolved as follows:</p>\n<ul>\n<li>If <code>X</code> contains a string index signature, <code>keyof X</code> is a union of <code>string</code>, <code>number</code>, and the literal types representing symbol-like properties, otherwise</li>\n<li>If <code>X</code> contains a numeric index signature, <code>keyof X</code> is a union of <code>number</code> and the literal types representing string-like and symbol-like properties, otherwise</li>\n<li><code>keyof X</code> is a union of the literal types representing string-like, number-like, and symbol-like properties.</li>\n</ul>\n<p>Where:</p>\n<ul>\n<li>String-like properties of an object type are those declared using an identifier, a string literal, or a computed property name of a string literal type.</li>\n<li>Number-like properties of an object type are those declared using a numeric literal or computed property name of a numeric literal type.</li>\n<li>Symbol-like properties of an object type are those declared using a computed property name of a unique symbol type.</li>\n</ul>\n<p>In a mapped type <code>{ [P in K]: XXX }</code>, each string literal type in <code>K</code> introduces a property with a string name, each numeric literal type in <code>K</code> introduces a property with a numeric name, and each unique symbol type in <code>K</code> introduces a property with a unique symbol name.\nFurthermore, if <code>K</code> includes type <code>string</code>, a string index signature is introduced, and if <code>K</code> includes type <code>number</code>, a numeric index signature is introduced.</p>\n<h4 id=\"example-5\" style=\"position:relative;\"><a href=\"#example-5\" aria-label=\"example 5 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> c = </span><span style=\"color: #A31515\">\"c\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> d = </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> e = Symbol();</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">enum</span><span style=\"color: #000000\"> E1 {</span>\n<span style=\"color: #000000\">  A,</span>\n<span style=\"color: #000000\">  B,</span>\n<span style=\"color: #000000\">  C</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">enum</span><span style=\"color: #000000\"> E2 {</span>\n<span style=\"color: #000000\">  A = </span><span style=\"color: #A31515\">\"A\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  B = </span><span style=\"color: #A31515\">\"B\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  C = </span><span style=\"color: #A31515\">\"C\"</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Foo = {</span>\n<span style=\"color: #000000\">  a: string; </span><span style=\"color: #008000\">// String-like name</span>\n<span style=\"color: #000000\">  5: string; </span><span style=\"color: #008000\">// Number-like name</span>\n<span style=\"color: #000000\">  [c]: string; </span><span style=\"color: #008000\">// String-like name</span>\n<span style=\"color: #000000\">  [d]: string; </span><span style=\"color: #008000\">// Number-like name</span>\n<span style=\"color: #000000\">  [e]: string; </span><span style=\"color: #008000\">// Symbol-like name</span>\n<span style=\"color: #000000\">  [E1.A]: string; </span><span style=\"color: #008000\">// Number-like name</span>\n<span style=\"color: #000000\">  [E2.A]: string; </span><span style=\"color: #008000\">// String-like name</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> K1 = </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> Foo; </span><span style=\"color: #008000\">// \"a\" | 5 | \"c\" | 10 | typeof e | E1.A | E2.A</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> K2 = Extract&lt;</span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> Foo, string&gt;; </span><span style=\"color: #008000\">// \"a\" | \"c\" | E2.A</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> K3 = Extract&lt;</span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> Foo, number&gt;; </span><span style=\"color: #008000\">// 5 | 10 | E1.A</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> K4 = Extract&lt;</span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> Foo, symbol&gt;; </span><span style=\"color: #008000\">// typeof e</span></code></div></pre>\n<p>Since <code>keyof</code> now reflects the presence of a numeric index signature by including type <code>number</code> in the key type, mapped types such as <code>Partial&#x3C;T></code> and <code>Readonly&#x3C;T></code> work correctly when applied to object types with numeric index signatures:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Arrayish&lt;T&gt; = {</span>\n<span style=\"color: #000000\">  length: number;</span>\n<span style=\"color: #000000\">  [x: number]: T;</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> ReadonlyArrayish&lt;T&gt; = Readonly&lt;Arrayish&lt;T&gt;&gt;;</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> map: ReadonlyArrayish&lt;string&gt;;</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> n = map.length;</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = map[</span><span style=\"color: #09835A\">123</span><span style=\"color: #000000\">]; </span><span style=\"color: #008000\">// Previously of type any (or an error with --noImplicitAny)</span></code></div></pre>\n<p>Furthermore, with the <code>keyof</code> operator’s support for <code>number</code> and <code>symbol</code> named keys, it is now possible to abstract over access to properties of objects that are indexed by numeric literals (such as numeric enum types) and unique symbols.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">enum</span><span style=\"color: #000000\"> Enum {</span>\n<span style=\"color: #000000\">  A,</span>\n<span style=\"color: #000000\">  B,</span>\n<span style=\"color: #000000\">  C</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> enumToStringMap = {</span>\n<span style=\"color: #000000\">  [Enum.A]: </span><span style=\"color: #A31515\">\"Name A\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  [Enum.B]: </span><span style=\"color: #A31515\">\"Name B\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  [Enum.C]: </span><span style=\"color: #A31515\">\"Name C\"</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> sym1 = Symbol();</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> sym2 = Symbol();</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> sym3 = Symbol();</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> symbolToNumberMap = {</span>\n<span style=\"color: #000000\">  [sym1]: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  [sym2]: </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  [sym3]: </span><span style=\"color: #09835A\">3</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> KE = </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> enumToStringMap; </span><span style=\"color: #008000\">// Enum (i.e. Enum.A | Enum.B | Enum.C)</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> KS = </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> symbolToNumberMap; </span><span style=\"color: #008000\">// typeof sym1 | typeof sym2 | typeof sym3</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> getValue&lt;T, K </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> T&gt;(obj: T, key: K): T[K] {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> obj[key];</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x1 = getValue(enumToStringMap, Enum.C); </span><span style=\"color: #008000\">// Returns \"Name C\"</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x2 = getValue(symbolToNumberMap, sym3); </span><span style=\"color: #008000\">// Returns 3</span></code></div></pre>\n<p>This is a breaking change; previously, the <code>keyof</code> operator and mapped types only supported <code>string</code> named properties.\nCode that assumed values typed with <code>keyof T</code> were always <code>string</code>s, will now be flagged as error.</p>\n<h4 id=\"example-6\" style=\"position:relative;\"><a href=\"#example-6\" aria-label=\"example 6 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> useKey&lt;T, K </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> T&gt;(o: T, k: K) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> name: string = k; </span><span style=\"color: #008000\">// Error: keyof T is not assignable to string</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h4 id=\"recommendations\" style=\"position:relative;\"><a href=\"#recommendations\" aria-label=\"recommendations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Recommendations</h4>\n<ul>\n<li>\n<p>If your functions are only able to handle string named property keys, use <code>Extract&#x3C;keyof T, string></code> in the declaration:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> useKey&lt;T, K </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Extract&lt;</span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> T, string&gt;&gt;(o: T, k: K) {</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> name: string = k; </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n</li>\n<li>\n<p>If your functions are open to handling all property keys, then the changes should be done down-stream:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> useKey&lt;T, K </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> T&gt;(o: T, k: K) {</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> name: string | number | symbol = k;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n</li>\n<li>Otherwise use <code>--keyofStringsOnly</code> compiler option to disable the new behavior.</li>\n</ul>\n<h2 id=\"generic-type-arguments-in-jsx-elements\" style=\"position:relative;\"><a href=\"#generic-type-arguments-in-jsx-elements\" aria-label=\"generic type arguments in jsx elements permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Generic type arguments in JSX elements</h2>\n<p>JSX elements now allow passing type arguments to generic components.</p>\n<h4 id=\"example-7\" style=\"position:relative;\"><a href=\"#example-7\" aria-label=\"example 7 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> GenericComponent&lt;P&gt; </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> React.Component&lt;P&gt; {</span>\n<span style=\"color: #000000\">  internalProp: P;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Props = { a: number; b: string };</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> x = &lt;GenericComponent&lt;Props&gt; a={10} b=</span><span style=\"color: #A31515\">\"hi\"</span><span style=\"color: #000000\"> /&gt;; </span><span style=\"color: #008000\">// OK</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> y = &lt;GenericComponent&lt;Props&gt; a={10} b={20} /&gt;; </span><span style=\"color: #008000\">// Error</span></code></div></pre>\n<h2 id=\"generic-type-arguments-in-generic-tagged-templates\" style=\"position:relative;\"><a href=\"#generic-type-arguments-in-generic-tagged-templates\" aria-label=\"generic type arguments in generic tagged templates permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Generic type arguments in generic tagged templates</h2>\n<p>Tagged templates are a form of invocation introduced in ECMAScript 2015.\nLike call expressions, generic functions may be used in a tagged template and TypeScript will infer the type arguments utilized.</p>\n<p>TypeScript 2.9 allows passing generic type arguments to tagged template strings.</p>\n<h4 id=\"example-8\" style=\"position:relative;\"><a href=\"#example-8\" aria-label=\"example 8 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> styledComponent&lt;Props&gt;(</span>\n<span style=\"color: #000000\">  strs: TemplateStringsArray</span>\n<span style=\"color: #000000\">): Component&lt;Props&gt;;</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> MyProps {</span>\n<span style=\"color: #000000\">  name: string;</span>\n<span style=\"color: #000000\">  age: number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #000000\">styledComponent&lt;MyProps&gt;</span><span style=\"color: #A31515\">`</span>\n<span style=\"color: #A31515\">  font-size: 1.5em;</span>\n<span style=\"color: #A31515\">  text-align: center;</span>\n<span style=\"color: #A31515\">  color: palevioletred;</span>\n<span style=\"color: #A31515\">`</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> tag&lt;T&gt;(strs: TemplateStringsArray, ...args: T[]): T;</span>\n\n<span style=\"color: #008000\">// inference fails because 'number' and 'string' are both candidates that conflict</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> a = tag&lt;string | number&gt;</span><span style=\"color: #A31515\">`</span><span style=\"color: #0000FF\">${</span><span style=\"color: #09835A\">100</span><span style=\"color: #0000FF\">}</span><span style=\"color: #A31515\"> </span><span style=\"color: #0000FF\">${</span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #0000FF\">}</span><span style=\"color: #A31515\">`</span><span style=\"color: #000000\">;</span></code></div></pre>\n<h2 id=\"import-types\" style=\"position:relative;\"><a href=\"#import-types\" aria-label=\"import types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>import</code> types</h2>\n<p>Modules can import types declared in other modules. But non-module global scripts cannot access types declared in modules. Enter <code>import</code> types.</p>\n<p>Using <code>import(\"mod\")</code> in a type annotation allows for reaching in a module and accessing its exported declaration without importing it.</p>\n<h4 id=\"example-9\" style=\"position:relative;\"><a href=\"#example-9\" aria-label=\"example 9 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<p>Given a declaration of a class <code>Pet</code> in a module file:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// module.d.ts</span>\n\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Pet {</span>\n<span style=\"color: #000000\">  name: string;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Can be used in a non-module file <code>global-script.ts</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// global-script.ts</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> adopt(p: import(</span><span style=\"color: #A31515\">\"./module\"</span><span style=\"color: #000000\">).Pet) {</span>\n<span style=\"color: #000000\">  console.log(</span><span style=\"color: #A31515\">`Adopting </span><span style=\"color: #0000FF\">${</span><span style=\"color: #A31515\">p.name</span><span style=\"color: #0000FF\">}</span><span style=\"color: #A31515\">...`</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>This also works in JSDoc comments to refer to types from other modules in <code>.js</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #008000\">// a.js</span>\n\n<span style=\"color: #008000\">/**</span>\n<span style=\"color: #008000\"> * </span><span style=\"color: #0000FF\">@param</span><span style=\"color: #008000\"> p { import(\"./module\").Pet }</span>\n<span style=\"color: #008000\"> */</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> walk(p) {</span>\n<span style=\"color: #000000\">  console.log(</span><span style=\"color: #A31515\">`Walking ${p.name}...`</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"relaxing-declaration-emit-visiblity-rules\" style=\"position:relative;\"><a href=\"#relaxing-declaration-emit-visiblity-rules\" aria-label=\"relaxing declaration emit visiblity rules permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Relaxing declaration emit visiblity rules</h2>\n<p>With <code>import</code> types available, many of the visibility errors reported during declaration file generation can be handled by the compiler without the need to change the input.</p>\n<p>For instance:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> { createHash } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"crypto\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> hash = createHash(</span><span style=\"color: #A31515\">\"sha256\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #008000\">//           ^^^^</span>\n<span style=\"color: #008000\">// Exported variable 'hash' has or is using name 'Hash' from external module \"crypto\" but cannot be named.</span></code></div></pre>\n<p>With TypeScript 2.9, no errors are reported, and now the generated file looks like:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> hash: import(</span><span style=\"color: #A31515\">\"crypto\"</span><span style=\"color: #000000\">).Hash;</span></code></div></pre>\n<h2 id=\"support-for-importmeta\" style=\"position:relative;\"><a href=\"#support-for-importmeta\" aria-label=\"support for importmeta permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for <code>import.meta</code></h2>\n<p>TypeScript 2.9 introduces support for <code>import.meta</code>, a new meta-property as described by the current <a href=\"https://github.com/tc39/proposal-import-meta\">TC39 proposal</a>.</p>\n<p>The type of <code>import.meta</code> is the global <code>ImportMeta</code> type which is defined in <code>lib.es5.d.ts</code>.\nThis interface is extremely limited.\nAdding well-known properties for Node or browsers requires interface merging and possibly a global augmentation depending on the context.</p>\n<h4 id=\"example-10\" style=\"position:relative;\"><a href=\"#example-10\" aria-label=\"example 10 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<p>Assuming that <code>__dirname</code> is always available on <code>import.meta</code>, the declaration would be done through reopening <code>ImportMeta</code> interface:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// node.d.ts</span>\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> ImportMeta {</span>\n<span style=\"color: #000000\">  __dirname: string;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>And usage would be:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\">.meta.__dirname; </span><span style=\"color: #008000\">// Has type 'string'</span></code></div></pre>\n<p><code>import.meta</code> is only allowed when targeting <code>ESNext</code> modules and ECMAScript targets.</p>\n<h2 id=\"new---resolvejsonmodule\" style=\"position:relative;\"><a href=\"#new---resolvejsonmodule\" aria-label=\"new   resolvejsonmodule permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New <code>--resolveJsonModule</code></h2>\n<p>Often in Node.js applications a <code>.json</code> is needed. With TypeScript 2.9, <code>--resolveJsonModule</code> allows for importing, extracting types from and generating <code>.json</code> files.</p>\n<h4 id=\"example-11\" style=\"position:relative;\"><a href=\"#example-11\" aria-label=\"example 11 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// settings.json</span>\n\n<span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #A31515\">\"repo\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"TypeScript\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #A31515\">\"dry\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #A31515\">\"debug\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">false</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// a.ts</span>\n\n<span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> settings </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./settings.json\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #000000\">settings.debug === </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #000000\">settings.dry === </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error: Operator '===' cannot be applied boolean and number</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// tsconfig.json</span>\n\n<span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #A31515\">\"compilerOptions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #A31515\">\"module\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"commonjs\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #A31515\">\"resolveJsonModule\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #A31515\">\"esModuleInterop\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"--pretty-output-by-default\" style=\"position:relative;\"><a href=\"#--pretty-output-by-default\" aria-label=\"  pretty output by default permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>--pretty</code> output by default</h2>\n<p>Starting TypeScript 2.9 errors are displayed under <code>--pretty</code> by default if the output device is applicable for colorful text.\nTypeScript will check if the output steam has <a href=\"https://nodejs.org/api/tty.html\"><code>isTty</code></a> property set.</p>\n<p>Use <code>--pretty false</code> on the command line or set <code>\"pretty\": false</code> in your <code>tsconfig.json</code> to disable <code>--pretty</code> output.</p>\n<h2 id=\"new---declarationmap\" style=\"position:relative;\"><a href=\"#new---declarationmap\" aria-label=\"new   declarationmap permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New <code>--declarationMap</code></h2>\n<p>Enabling <code>--declarationMap</code> alongside <code>--declaration</code> causes the compiler to emit <code>.d.ts.map</code> files alongside the output <code>.d.ts</code> files.\nLanguage Services can also now understand these map files, and uses them to map declaration-file based definition locations to their original source, when available.</p>\n<p>In other words, hitting go-to-definition on a declaration from a <code>.d.ts</code> file generated with <code>--declarationMap</code> will take you to the source file (<code>.ts</code>) location where that declaration was defined, and not to the <code>.d.ts</code>.</p>\n<h2 id=\"typescript-28\" style=\"position:relative;\"><a href=\"#typescript-28\" aria-label=\"typescript 28 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 2.8</h2>\n<h2 id=\"conditional-types\" style=\"position:relative;\"><a href=\"#conditional-types\" aria-label=\"conditional types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Conditional Types</h2>\n<p>TypeScript 2.8 introduces <em>conditional types</em> which add the ability to express non-uniform type mappings.\nA conditional type selects one of two possible types based on a condition expressed as a type relationship test:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #000000\">T extends U ? X : Y</span></code></div></pre>\n<p>The type above means when <code>T</code> is assignable to <code>U</code> the type is <code>X</code>, otherwise the type is <code>Y</code>.</p>\n<p>A conditional type <code>T extends U ? X : Y</code> is either <em>resolved</em> to <code>X</code> or <code>Y</code>, or <em>deferred</em> because the condition depends on one or more type variables.\nWhether to resolve or defer is determined as follows:</p>\n<ul>\n<li>First, given types <code>T'</code> and <code>U'</code> that are instantiations of <code>T</code> and <code>U</code> where all occurrences of type parameters are replaced with <code>any</code>, if <code>T'</code> is not assignable to <code>U'</code>, the conditional type is resolved to <code>Y</code>. Intuitively, if the most permissive instantiation of <code>T</code> is not assignable to the most permissive instantiation of <code>U</code>, we know that no instantiation will be and we can just resolve to <code>Y</code>.</li>\n<li>Next, for each type variable introduced by an <code>infer</code> (more later) declaration within <code>U</code> collect a set of candidate types by inferring from <code>T</code> to <code>U</code> (using the same inference algorithm as type inference for generic functions). For a given <code>infer</code> type variable <code>V</code>, if any candidates were inferred from co-variant positions, the type inferred for <code>V</code> is a union of those candidates. Otherwise, if any candidates were inferred from contra-variant positions, the type inferred for <code>V</code> is an intersection of those candidates. Otherwise, the type inferred for <code>V</code> is <code>never</code>.</li>\n<li>Then, given a type <code>T''</code> that is an instantiation of <code>T</code> where all <code>infer</code> type variables are replaced with the types inferred in the previous step, if <code>T''</code> is <em>definitely assignable</em> to <code>U</code>, the conditional type is resolved to <code>X</code>. The definitely assignable relation is the same as the regular assignable relation, except that type variable constraints are not considered. Intuitively, when a type is definitely assignable to another type, we know that it will be assignable for <em>all instantiations</em> of those types.</li>\n<li>Otherwise, the condition depends on one or more type variables and the conditional type is deferred.</li>\n</ul>\n<h4 id=\"example-12\" style=\"position:relative;\"><a href=\"#example-12\" aria-label=\"example 12 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> TypeName&lt;T&gt; = T extends string</span>\n<span style=\"color: #000000\">  ? </span><span style=\"color: #A31515\">\"string\"</span>\n<span style=\"color: #000000\">  : T extends number</span>\n<span style=\"color: #000000\">  ? </span><span style=\"color: #A31515\">\"number\"</span>\n<span style=\"color: #000000\">  : T extends boolean</span>\n<span style=\"color: #000000\">  ? </span><span style=\"color: #A31515\">\"boolean\"</span>\n<span style=\"color: #000000\">  : T extends undefined</span>\n<span style=\"color: #000000\">  ? </span><span style=\"color: #A31515\">\"undefined\"</span>\n<span style=\"color: #000000\">  : T extends Function</span>\n<span style=\"color: #000000\">  ? </span><span style=\"color: #A31515\">\"function\"</span>\n<span style=\"color: #000000\">  : </span><span style=\"color: #A31515\">\"object\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T0 = TypeName&lt;string&gt;; </span><span style=\"color: #008000\">// \"string\"</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T1 = TypeName&lt;</span><span style=\"color: #A31515\">\"a\"</span><span style=\"color: #000000\">&gt;; </span><span style=\"color: #008000\">// \"string\"</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T2 = TypeName&lt;true&gt;; </span><span style=\"color: #008000\">// \"boolean\"</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T3 = TypeName&lt;() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void&gt;; </span><span style=\"color: #008000\">// \"function\"</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T4 = TypeName&lt;string[]&gt;; </span><span style=\"color: #008000\">// \"object\"</span></code></div></pre>\n<h3 id=\"distributive-conditional-types\" style=\"position:relative;\"><a href=\"#distributive-conditional-types\" aria-label=\"distributive conditional types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Distributive conditional types</h3>\n<p>Conditional types in which the checked type is a naked type parameter are called <em>distributive conditional types</em>.\nDistributive conditional types are automatically distributed over union types during instantiation.\nFor example, an instantiation of <code>T extends U ? X : Y</code> with the type argument <code>A | B | C</code> for <code>T</code> is resolved as <code>(A extends U ? X : Y) | (B extends U ? X : Y) | (C extends U ? X : Y)</code>.</p>\n<h4 id=\"example-13\" style=\"position:relative;\"><a href=\"#example-13\" aria-label=\"example 13 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T10 = TypeName&lt;string | (() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void)&gt;; </span><span style=\"color: #008000\">// \"string\" | \"function\"</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T12 = TypeName&lt;string | string[] | undefined&gt;; </span><span style=\"color: #008000\">// \"string\" | \"object\" | \"undefined\"</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T11 = TypeName&lt;string[] | number[]&gt;; </span><span style=\"color: #008000\">// \"object\"</span></code></div></pre>\n<p>In instantiations of a distributive conditional type <code>T extends U ? X : Y</code>, references to <code>T</code> within the conditional type are resolved to individual constituents of the union type (i.e. <code>T</code> refers to the individual constituents <em>after</em> the conditional type is distributed over the union type).\nFurthermore, references to <code>T</code> within <code>X</code> have an additional type parameter constraint <code>U</code> (i.e. <code>T</code> is considered assignable to <code>U</code> within <code>X</code>).</p>\n<h4 id=\"example-14\" style=\"position:relative;\"><a href=\"#example-14\" aria-label=\"example 14 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> BoxedValue&lt;T&gt; = { value: T };</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> BoxedArray&lt;T&gt; = { array: T[] };</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Boxed&lt;T&gt; = T extends any[] ? BoxedArray&lt;T[number]&gt; : BoxedValue&lt;T&gt;;</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T20 = Boxed&lt;string&gt;; </span><span style=\"color: #008000\">// BoxedValue&lt;string&gt;;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T21 = Boxed&lt;number[]&gt;; </span><span style=\"color: #008000\">// BoxedArray&lt;number&gt;;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T22 = Boxed&lt;string | number[]&gt;; </span><span style=\"color: #008000\">// BoxedValue&lt;string&gt; | BoxedArray&lt;number&gt;;</span></code></div></pre>\n<p>Notice that <code>T</code> has the additional constraint <code>any[]</code> within the true branch of <code>Boxed&#x3C;T></code> and it is therefore possible to refer to the element type of the array as <code>T[number]</code>. Also, notice how the conditional type is distributed over the union type in the last example.</p>\n<p>The distributive property of conditional types can conveniently be used to <em>filter</em> union types:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Diff&lt;T, U&gt; = T extends U ? never : T; </span><span style=\"color: #008000\">// Remove types from T that are assignable to U</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Filter&lt;T, U&gt; = T extends U ? T : never; </span><span style=\"color: #008000\">// Remove types from T that are not assignable to U</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T30 = Diff&lt;</span><span style=\"color: #A31515\">\"a\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"b\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"c\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"d\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"a\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"c\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"f\"</span><span style=\"color: #000000\">&gt;; </span><span style=\"color: #008000\">// \"b\" | \"d\"</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T31 = Filter&lt;</span><span style=\"color: #A31515\">\"a\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"b\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"c\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"d\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"a\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"c\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"f\"</span><span style=\"color: #000000\">&gt;; </span><span style=\"color: #008000\">// \"a\" | \"c\"</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T32 = Diff&lt;string | number | (() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void), Function&gt;; </span><span style=\"color: #008000\">// string | number</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T33 = Filter&lt;string | number | (() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void), Function&gt;; </span><span style=\"color: #008000\">// () =&gt; void</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> NonNullable&lt;T&gt; = Diff&lt;T, null | undefined&gt;; </span><span style=\"color: #008000\">// Remove null and undefined from T</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T34 = NonNullable&lt;string | number | undefined&gt;; </span><span style=\"color: #008000\">// string | number</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T35 = NonNullable&lt;string | string[] | null | undefined&gt;; </span><span style=\"color: #008000\">// string | string[]</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f1&lt;T&gt;(x: T, y: NonNullable&lt;T&gt;) {</span>\n<span style=\"color: #000000\">  x = y; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">  y = x; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f2&lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> string | undefined&gt;(x: T, y: NonNullable&lt;T&gt;) {</span>\n<span style=\"color: #000000\">  x = y; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">  y = x; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> s1: string = x; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> s2: string = y; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Conditional types are particularly useful when combined with mapped types:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> FunctionPropertyNames&lt;T&gt; = {</span>\n<span style=\"color: #000000\">  [K </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> keyof T]: T[K] extends Function ? K : never;</span>\n<span style=\"color: #000000\">}[</span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> T];</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> FunctionProperties&lt;T&gt; = Pick&lt;T, FunctionPropertyNames&lt;T&gt;&gt;;</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> NonFunctionPropertyNames&lt;T&gt; = {</span>\n<span style=\"color: #000000\">  [K </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> keyof T]: T[K] extends Function ? never : K;</span>\n<span style=\"color: #000000\">}[</span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> T];</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> NonFunctionProperties&lt;T&gt; = Pick&lt;T, NonFunctionPropertyNames&lt;T&gt;&gt;;</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Part {</span>\n<span style=\"color: #000000\">  id: number;</span>\n<span style=\"color: #000000\">  name: string;</span>\n<span style=\"color: #000000\">  subparts: Part[];</span>\n<span style=\"color: #000000\">  updatePart(newName: string): void;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T40 = FunctionPropertyNames&lt;Part&gt;; </span><span style=\"color: #008000\">// \"updatePart\"</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T41 = NonFunctionPropertyNames&lt;Part&gt;; </span><span style=\"color: #008000\">// \"id\" | \"name\" | \"subparts\"</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T42 = FunctionProperties&lt;Part&gt;; </span><span style=\"color: #008000\">// { updatePart(newName: string): void }</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T43 = NonFunctionProperties&lt;Part&gt;; </span><span style=\"color: #008000\">// { id: number, name: string, subparts: Part[] }</span></code></div></pre>\n<p>Similar to union and intersection types, conditional types are not permitted to reference themselves recursively. For example the following is an error.</p>\n<h4 id=\"example-15\" style=\"position:relative;\"><a href=\"#example-15\" aria-label=\"example 15 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> ElementType&lt;T&gt; = T extends any[] ? ElementType&lt;T[number]&gt; : T; </span><span style=\"color: #008000\">// Error</span></code></div></pre>\n<h3 id=\"type-inference-in-conditional-types\" style=\"position:relative;\"><a href=\"#type-inference-in-conditional-types\" aria-label=\"type inference in conditional types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Type inference in conditional types</h3>\n<p>Within the <code>extends</code> clause of a conditional type, it is now possible to have <code>infer</code> declarations that introduce a type variable to be inferred.\nSuch inferred type variables may be referenced in the true branch of the conditional type.\nIt is possible to have multiple <code>infer</code> locations for the same type variable.</p>\n<p>For example, the following extracts the return type of a function type:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> ReturnType&lt;T&gt; = T extends (...args: any[]) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> infer R ? R : any;</span></code></div></pre>\n<p>Conditional types can be nested to form a sequence of pattern matches that are evaluated in order:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Unpacked&lt;T&gt; = T extends (infer U)[]</span>\n<span style=\"color: #000000\">  ? U</span>\n<span style=\"color: #000000\">  : T extends (...args: any[]) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> infer U</span>\n<span style=\"color: #000000\">  ? U</span>\n<span style=\"color: #000000\">  : T extends Promise&lt;infer U&gt;</span>\n<span style=\"color: #000000\">  ? U</span>\n<span style=\"color: #000000\">  : T;</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T0 = Unpacked&lt;string&gt;; </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T1 = Unpacked&lt;string[]&gt;; </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T2 = Unpacked&lt;() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> string&gt;; </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T3 = Unpacked&lt;Promise&lt;string&gt;&gt;; </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T4 = Unpacked&lt;Promise&lt;string&gt;[]&gt;; </span><span style=\"color: #008000\">// Promise&lt;string&gt;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T5 = Unpacked&lt;Unpacked&lt;Promise&lt;string&gt;[]&gt;&gt;; </span><span style=\"color: #008000\">// string</span></code></div></pre>\n<p>The following example demonstrates how multiple candidates for the same type variable in co-variant positions causes a union type to be inferred:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Foo&lt;T&gt; = T extends { a: infer U; b: infer U } ? U : never;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T10 = Foo&lt;{ a: string; b: string }&gt;; </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T11 = Foo&lt;{ a: string; b: number }&gt;; </span><span style=\"color: #008000\">// string | number</span></code></div></pre>\n<p>Likewise, multiple candidates for the same type variable in contra-variant positions causes an intersection type to be inferred:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Bar&lt;T&gt; = T extends { a: (x: infer U) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void; b: (x: infer U) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void }</span>\n<span style=\"color: #000000\">  ? U</span>\n<span style=\"color: #000000\">  : never;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T20 = Bar&lt;{ a: (x: string) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void; b: (x: string) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void }&gt;; </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T21 = Bar&lt;{ a: (x: string) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void; b: (x: number) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void }&gt;; </span><span style=\"color: #008000\">// string & number</span></code></div></pre>\n<p>When inferring from a type with multiple call signatures (such as the type of an overloaded function), inferences are made from the <em>last</em> signature (which, presumably, is the most permissive catch-all case).\nIt is not possible to perform overload resolution based on a list of argument types.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> foo(x: string): number;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> foo(x: number): string;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> foo(x: string | number): string | number;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T30 = ReturnType&lt;</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> foo&gt;; </span><span style=\"color: #008000\">// string | number</span></code></div></pre>\n<p>It is not possible to use <code>infer</code> declarations in constraint clauses for regular type parameters:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> ReturnType&lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> (...args: any[]) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> infer R&gt; = R; </span><span style=\"color: #008000\">// Error, not supported</span></code></div></pre>\n<p>However, much the same effect can be obtained by erasing the type variables in the constraint and instead specifying a conditional type:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> AnyFunction = (...args: any[]) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> any;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> ReturnType&lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> AnyFunction&gt; = T extends (...args: any[]) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> infer R</span>\n<span style=\"color: #000000\">  ? R</span>\n<span style=\"color: #000000\">  : any;</span></code></div></pre>\n<h3 id=\"predefined-conditional-types\" style=\"position:relative;\"><a href=\"#predefined-conditional-types\" aria-label=\"predefined conditional types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Predefined conditional types</h3>\n<p>TypeScript 2.8 adds several predefined conditional types to <code>lib.d.ts</code>:</p>\n<ul>\n<li><code>Exclude&#x3C;T, U></code> — Exclude from <code>T</code> those types that are assignable to <code>U</code>.</li>\n<li><code>Extract&#x3C;T, U></code> — Extract from <code>T</code> those types that are assignable to <code>U</code>.</li>\n<li><code>NonNullable&#x3C;T></code> — Exclude <code>null</code> and <code>undefined</code> from <code>T</code>.</li>\n<li><code>ReturnType&#x3C;T></code> — Obtain the return type of a function type.</li>\n<li><code>InstanceType&#x3C;T></code> — Obtain the instance type of a constructor function type.</li>\n</ul>\n<h4 id=\"example-16\" style=\"position:relative;\"><a href=\"#example-16\" aria-label=\"example 16 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T00 = Exclude&lt;</span><span style=\"color: #A31515\">\"a\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"b\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"c\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"d\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"a\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"c\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"f\"</span><span style=\"color: #000000\">&gt;; </span><span style=\"color: #008000\">// \"b\" | \"d\"</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T01 = Extract&lt;</span><span style=\"color: #A31515\">\"a\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"b\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"c\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"d\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"a\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"c\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"f\"</span><span style=\"color: #000000\">&gt;; </span><span style=\"color: #008000\">// \"a\" | \"c\"</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T02 = Exclude&lt;string | number | (() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void), Function&gt;; </span><span style=\"color: #008000\">// string | number</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T03 = Extract&lt;string | number | (() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void), Function&gt;; </span><span style=\"color: #008000\">// () =&gt; void</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T04 = NonNullable&lt;string | number | undefined&gt;; </span><span style=\"color: #008000\">// string | number</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T05 = NonNullable&lt;(() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> string) | string[] | null | undefined&gt;; </span><span style=\"color: #008000\">// (() =&gt; string) | string[]</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f1(s: string) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> { a: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, b: s };</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  x = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  y = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T10 = ReturnType&lt;() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> string&gt;; </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T11 = ReturnType&lt;(s: string) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void&gt;; </span><span style=\"color: #008000\">// void</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T12 = ReturnType&lt;&lt;T&gt;() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> T&gt;; </span><span style=\"color: #008000\">// {}</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T13 = ReturnType&lt;&lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> U, U </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> number[]&gt;() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> T&gt;; </span><span style=\"color: #008000\">// number[]</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T14 = ReturnType&lt;</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> f1&gt;; </span><span style=\"color: #008000\">// { a: number, b: string }</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T15 = ReturnType&lt;any&gt;; </span><span style=\"color: #008000\">// any</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T16 = ReturnType&lt;never&gt;; </span><span style=\"color: #008000\">// any</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T17 = ReturnType&lt;string&gt;; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T18 = ReturnType&lt;Function&gt;; </span><span style=\"color: #008000\">// Error</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T20 = InstanceType&lt;</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> C&gt;; </span><span style=\"color: #008000\">// C</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T21 = InstanceType&lt;any&gt;; </span><span style=\"color: #008000\">// any</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T22 = InstanceType&lt;never&gt;; </span><span style=\"color: #008000\">// any</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T23 = InstanceType&lt;string&gt;; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T24 = InstanceType&lt;Function&gt;; </span><span style=\"color: #008000\">// Error</span></code></div></pre>\n<blockquote>\n<p>Note: The <code>Exclude</code> type is a proper implementation of the <code>Diff</code> type suggested <a href=\"https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-307871458\">here</a>. We’ve used the name <code>Exclude</code> to avoid breaking existing code that defines a <code>Diff</code>, plus we feel that name better conveys the semantics of the type. We did not include the <code>Omit&#x3C;T, K></code> type because it is trivially written as <code>Pick&#x3C;T, Exclude&#x3C;keyof T, K>></code>.</p>\n</blockquote>\n<h2 id=\"improved-control-over-mapped-type-modifiers\" style=\"position:relative;\"><a href=\"#improved-control-over-mapped-type-modifiers\" aria-label=\"improved control over mapped type modifiers permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Improved control over mapped type modifiers</h2>\n<p>Mapped types support adding a <code>readonly</code> or <code>?</code> modifier to a mapped property, but they did not provide support the ability to <em>remove</em> modifiers.\nThis matters in <a href=\"https://github.com/Microsoft/TypeScript/pull/12563\"><em>homomorphic mapped types</em></a> which by default preserve the modifiers of the underlying type.</p>\n<p>TypeScript 2.8 adds the ability for a mapped type to either add or remove a particular modifier.\nSpecifically, a <code>readonly</code> or <code>?</code> property modifier in a mapped type can now be prefixed with either <code>+</code> or <code>-</code> to indicate that the modifier should be added or removed.</p>\n<h4 id=\"example-17\" style=\"position:relative;\"><a href=\"#example-17\" aria-label=\"example 17 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> MutableRequired&lt;T&gt; = { -readonly [P in keyof T]-?: T[P] }; </span><span style=\"color: #008000\">// Remove readonly and ?</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> ReadonlyPartial&lt;T&gt; = { +readonly [P in keyof T]+?: T[P] }; </span><span style=\"color: #008000\">// Add readonly and ?</span></code></div></pre>\n<p>A modifier with no <code>+</code> or <code>-</code> prefix is the same as a modifier with a <code>+</code> prefix. So, the <code>ReadonlyPartial&#x3C;T></code> type above corresponds to</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> ReadonlyPartial&lt;T&gt; = { </span><span style=\"color: #0000FF\">readonly</span><span style=\"color: #000000\"> [P </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> keyof T]?: T[P] }; </span><span style=\"color: #008000\">// Add readonly and ?</span></code></div></pre>\n<p>Using this ability, <code>lib.d.ts</code> now has a new <code>Required&#x3C;T></code> type.\nThis type strips <code>?</code> modifiers from all properties of <code>T</code>, thus making all properties required.</p>\n<h4 id=\"example-18\" style=\"position:relative;\"><a href=\"#example-18\" aria-label=\"example 18 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Required&lt;T&gt; = { [P in keyof T]-?: T[P] };</span></code></div></pre>\n<p>Note that in <code>--strictNullChecks</code> mode, when a homomorphic mapped type removes a <code>?</code> modifier from a property in the underlying type it also removes <code>undefined</code> from the type of that property:</p>\n<h4 id=\"example-19\" style=\"position:relative;\"><a href=\"#example-19\" aria-label=\"example 19 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Foo = { a?: string }; </span><span style=\"color: #008000\">// Same as { a?: string | undefined }</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Bar = Required&lt;Foo&gt;; </span><span style=\"color: #008000\">// Same as { a: string }</span></code></div></pre>\n<h2 id=\"improved-keyof-with-intersection-types\" style=\"position:relative;\"><a href=\"#improved-keyof-with-intersection-types\" aria-label=\"improved keyof with intersection types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Improved <code>keyof</code> with intersection types</h2>\n<p>With TypeScript 2.8 <code>keyof</code> applied to an intersection type is transformed to a union of <code>keyof</code> applied to each intersection constituent.\nIn other words, types of the form <code>keyof (A &#x26; B)</code> are transformed to be <code>keyof A | keyof B</code>.\nThis change should address inconsistencies with inference from <code>keyof</code> expressions.</p>\n<h4 id=\"example-20\" style=\"position:relative;\"><a href=\"#example-20\" aria-label=\"example 20 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> A = { a: string };</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> B = { b: string };</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T1 = </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> (A & B); </span><span style=\"color: #008000\">// \"a\" | \"b\"</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T2&lt;T&gt; = </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> (T & B); </span><span style=\"color: #008000\">// keyof T | \"b\"</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T3&lt;U&gt; = </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> (A & U); </span><span style=\"color: #008000\">// \"a\" | keyof U</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T4&lt;T, U&gt; = </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> (T & U); </span><span style=\"color: #008000\">// keyof T | keyof U</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T5 = T2&lt;A&gt;; </span><span style=\"color: #008000\">// \"a\" | \"b\"</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T6 = T3&lt;B&gt;; </span><span style=\"color: #008000\">// \"a\" | \"b\"</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T7 = T4&lt;A, B&gt;; </span><span style=\"color: #008000\">// \"a\" | \"b\"</span></code></div></pre>\n<h2 id=\"better-handling-for-namespace-patterns-in-js-files\" style=\"position:relative;\"><a href=\"#better-handling-for-namespace-patterns-in-js-files\" aria-label=\"better handling for namespace patterns in js files permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Better handling for namespace patterns in <code>.js</code> files</h2>\n<p>TypeScript 2.8 adds support for understanding more namespace patterns in <code>.js</code> files.\nEmpty object literals declarations on top level, just like functions and classes, are now recognized as as namespace declarations in JavaScript.</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> ns = {}; </span><span style=\"color: #008000\">// recognized as a declaration for a namespace `ns`</span>\n<span style=\"color: #000000\">ns.constant = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// recognized as a declaration for var `constant`</span></code></div></pre>\n<p>Assignments at the top-level should behave the same way; in other words, a <code>var</code> or <code>const</code> declaration is not required.</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #000000\">app = {}; </span><span style=\"color: #008000\">// does NOT need to be `var app = {}`</span>\n<span style=\"color: #000000\">app.C = </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> {};</span>\n<span style=\"color: #000000\">app.f = </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">() {};</span>\n<span style=\"color: #000000\">app.prop = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span></code></div></pre>\n<h3 id=\"iifes-as-namespace-declarations\" style=\"position:relative;\"><a href=\"#iifes-as-namespace-declarations\" aria-label=\"iifes as namespace declarations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>IIFEs as namespace declarations</h3>\n<p>An IIFE returning a function, class or empty object literal, is also recognized as a namespace:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> C = (</span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> C(n) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.p = n;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> C;</span>\n<span style=\"color: #000000\">})();</span>\n<span style=\"color: #000000\">C.staticProperty = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span></code></div></pre>\n<h3 id=\"defaulted-declarations\" style=\"position:relative;\"><a href=\"#defaulted-declarations\" aria-label=\"defaulted declarations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Defaulted declarations</h3>\n<p>“Defaulted declarations” allow initializers that reference the declared name in the left side of a logical or:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #000000\">my = window.my || {};</span>\n<span style=\"color: #000000\">my.app = my.app || {};</span></code></div></pre>\n<h3 id=\"prototype-assignment\" style=\"position:relative;\"><a href=\"#prototype-assignment\" aria-label=\"prototype assignment permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Prototype assignment</h3>\n<p>You can assign an object literal directly to the prototype property. Individual prototype assignments still work too:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> C = </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(p) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.p = p;</span>\n<span style=\"color: #000000\">};</span>\n<span style=\"color: #000000\">C.prototype = {</span>\n<span style=\"color: #000000\">  m() {</span>\n<span style=\"color: #000000\">    console.log(</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.p);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">};</span>\n<span style=\"color: #000000\">C.prototype.q = </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(r) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.p === r;</span>\n<span style=\"color: #000000\">};</span></code></div></pre>\n<h3 id=\"nested-and-merged-declarations\" style=\"position:relative;\"><a href=\"#nested-and-merged-declarations\" aria-label=\"nested and merged declarations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Nested and merged declarations</h3>\n<p>Nesting works to any level now, and merges correctly across files. Previously neither was the case.</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> app = window.app || {};</span>\n<span style=\"color: #000000\">app.C = </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> {};</span></code></div></pre>\n<h2 id=\"per-file-jsx-factories\" style=\"position:relative;\"><a href=\"#per-file-jsx-factories\" aria-label=\"per file jsx factories permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Per-file JSX factories</h2>\n<p>TypeScript 2.8 adds support for a per-file configurable JSX factory name using <code>@jsx dom</code> paragma.\nJSX factory can be configured for a compilation using <code>--jsxFactory</code> (default is <code>React.createElement</code>). With TypeScript 2.8 you can override this on a per-file-basis by adding a comment to the beginning of the file.</p>\n<h4 id=\"example-21\" style=\"position:relative;\"><a href=\"#example-21\" aria-label=\"example 21 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">/** @jsx dom */</span>\n<span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> { dom } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./renderer\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">&lt;h&gt;&lt;/h&gt;;</span></code></div></pre>\n<p>Generates:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> renderer_1 = require(</span><span style=\"color: #A31515\">\"./renderer\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">renderer_1.dom(</span><span style=\"color: #A31515\">\"h\"</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">);</span></code></div></pre>\n<h2 id=\"locally-scoped-jsx-namespaces\" style=\"position:relative;\"><a href=\"#locally-scoped-jsx-namespaces\" aria-label=\"locally scoped jsx namespaces permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Locally scoped JSX namespaces</h2>\n<p>JSX type checking is driven by definitions in a JSX namespace, for instance <code>JSX.Element</code> for the type of a JSX element, and <code>JSX.IntrinsicElements</code> for built-in elements.\nBefore TypeScript 2.8 the <code>JSX</code> namespace was expected to be in the global namespace, and thus only allowing one to be defined in a project.\nStarting with TypeScript 2.8 the <code>JSX</code> namespace will be looked under the <code>jsxNamespace</code> (e.g. <code>React</code>) allowing for multiple jsx factories in one compilation.\nFor backward compatibility the global <code>JSX</code> namespace is used as a fallback if none was defined on the factory function.\nCombined with the per-file <code>@jsx</code> pragma, each file can have a different JSX factory.</p>\n<h2 id=\"new---emitdeclarationsonly\" style=\"position:relative;\"><a href=\"#new---emitdeclarationsonly\" aria-label=\"new   emitdeclarationsonly permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New <code>--emitDeclarationsOnly</code></h2>\n<p><code>--emitDeclarationsOnly</code> allows for <em>only</em> generating declaration files; <code>.js</code>/<code>.jsx</code> output generation will be skipped with this flag. The flag is useful when the <code>.js</code> output generation is handled by a different transpiler like Babel.</p>\n<h2 id=\"typescript-27\" style=\"position:relative;\"><a href=\"#typescript-27\" aria-label=\"typescript 27 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 2.7</h2>\n<h2 id=\"constant-named-properties\" style=\"position:relative;\"><a href=\"#constant-named-properties\" aria-label=\"constant named properties permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Constant-named properties</h2>\n<p>TypeScript 2.7 adds support for declaring const-named properties on types including ECMAScript symbols.</p>\n<h4 id=\"example-22\" style=\"position:relative;\"><a href=\"#example-22\" aria-label=\"example 22 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Lib</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> SERIALIZE = Symbol(</span><span style=\"color: #A31515\">\"serialize-method-key\"</span><span style=\"color: #000000\">);</span>\n\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Serializable {</span>\n<span style=\"color: #000000\">  [SERIALIZE](obj: {}): string;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// consumer</span>\n\n<span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> { SERIALIZE, Serializable } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"lib\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> JSONSerializableItem </span><span style=\"color: #0000FF\">implements</span><span style=\"color: #000000\"> Serializable {</span>\n<span style=\"color: #000000\">  [SERIALIZE](obj: {}) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> JSON.stringify(obj);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>This also applies to numeric and string literals.</p>\n<h4 id=\"example-23\" style=\"position:relative;\"><a href=\"#example-23\" aria-label=\"example 23 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> Foo = </span><span style=\"color: #A31515\">\"Foo\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> Bar = </span><span style=\"color: #A31515\">\"Bar\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = {</span>\n<span style=\"color: #000000\">  [Foo]: </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  [Bar]: </span><span style=\"color: #A31515\">\"hello\"</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> a = x[Foo]; </span><span style=\"color: #008000\">// has type 'number'</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> b = x[Bar]; </span><span style=\"color: #008000\">// has type 'string'</span></code></div></pre>\n<h3 id=\"unique-symbol\" style=\"position:relative;\"><a href=\"#unique-symbol\" aria-label=\"unique symbol permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>unique symbol</code></h3>\n<p>To enable treating symbols as unique literals a new type <code>unique symbol</code> is available.\n<code>unique symbol</code> is are subtype of <code>symbol</code>, and are produced only from calling <code>Symbol()</code> or <code>Symbol.for()</code>, or from explicit type annotations.\nThe new type is only allowed on <code>const</code> declarations and <code>readonly static</code> properties, and in order to reference a specific unique symbol, you’ll have to use the <code>typeof</code> operator.\nEach reference to a <code>unique symbol</code> implies a completely unique identity that’s tied to a given declaration.</p>\n<h4 id=\"example-24\" style=\"position:relative;\"><a href=\"#example-24\" aria-label=\"example 24 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Works</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> Foo: unique symbol;</span>\n\n<span style=\"color: #008000\">// Error! 'Bar' isn't a constant.</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> Bar: unique symbol = Symbol();</span>\n\n<span style=\"color: #008000\">// Works - refers to a unique symbol, but its identity is tied to 'Foo'.</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> Baz: </span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> Foo = Foo;</span>\n\n<span style=\"color: #008000\">// Also works.</span>\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">static</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">readonly</span><span style=\"color: #000000\"> StaticSymbol: unique symbol = Symbol();</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Because each <code>unique symbol</code> has a completely separate identity, no two <code>unique symbol</code> types are assignable or comparable to each other.</p>\n<h4 id=\"example-25\" style=\"position:relative;\"><a href=\"#example-25\" aria-label=\"example 25 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> Foo = Symbol();</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> Bar = Symbol();</span>\n\n<span style=\"color: #008000\">// Error: can't compare two unique symbols.</span>\n<span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (Foo === Bar) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// ...</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"strict-class-initialization\" style=\"position:relative;\"><a href=\"#strict-class-initialization\" aria-label=\"strict class initialization permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Strict Class Initialization</h2>\n<p>TypeScript 2.7 introduces a new flag called <code>--strictPropertyInitialization</code>.\nThis flag performs checks to ensure that each instance property of a class gets initialized in the constructor body, or by a property initializer.\nFor example</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  foo: number;</span>\n<span style=\"color: #000000\">  bar = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  baz: boolean;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//  ~~~</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//  Error! Property 'baz' has no initializer and is not definitely assigned in the</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//         constructor.</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.foo = </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>In the above, if we truly meant for <code>baz</code> to potentially be <code>undefined</code>, we should have declared it with the type <code>boolean | undefined</code>.</p>\n<p>There are certain scenarios where properties can be initialized indirectly (perhaps by a helper method or dependency injection library), in which case you can use the new <em>definite assignment assertion modifiers</em> for your properties (discussed below).</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  foo!: number;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// ^</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Notice this '!' modifier.</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// This is the \"definite assignment assertion\"</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.initialize();</span>\n<span style=\"color: #000000\">  }</span>\n\n<span style=\"color: #000000\">  initialize() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.foo = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Keep in mind that <code>--strictPropertyInitialization</code> will be turned on along with other <code>--strict</code> mode flags, which can impact your project.\nYou can set the <code>strictPropertyInitialization</code> setting to <code>false</code> in your <code>tsconfig.json</code>’s <code>compilerOptions</code>, or <code>--strictPropertyInitialization false</code> on the command line to turn off this checking.</p>\n<h2 id=\"definite-assignment-assertions\" style=\"position:relative;\"><a href=\"#definite-assignment-assertions\" aria-label=\"definite assignment assertions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Definite Assignment Assertions</h2>\n<p>The definite assignment assertion is a feature that allows a <code>!</code> to be placed after instance property and variable declarations to relay to TypeScript that a variable is indeed assigned for all intents and purposes, even if TypeScript’s analyses cannot detect so.</p>\n<p>For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: number;</span>\n<span style=\"color: #000000\">initialize();</span>\n<span style=\"color: #000000\">console.log(x + x);</span>\n<span style=\"color: #008000\">//          ~   ~</span>\n<span style=\"color: #008000\">// Error! Variable 'x' is used before being assigned.</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> initialize() {</span>\n<span style=\"color: #000000\">  x = </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>With definite assignment assertions, we can assert that <code>x</code> is really assigned by appending an <code>!</code> to its declaration:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Notice the '!'</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x!: number;</span>\n<span style=\"color: #000000\">initialize();</span>\n\n<span style=\"color: #008000\">// No error!</span>\n<span style=\"color: #000000\">console.log(x + x);</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> initialize() {</span>\n<span style=\"color: #000000\">  x = </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>In a sense, the definite assignment assertion operator is the dual of the non-null assertion operator (in which <em>expressions</em> are post-fixed with a <code>!</code>), which we could also have used in the example.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: number;</span>\n<span style=\"color: #000000\">initialize();</span>\n\n<span style=\"color: #008000\">// No error!</span>\n<span style=\"color: #000000\">console.log(x! + x!);</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> initialize() {</span>\n<span style=\"color: #000000\">    x = </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>In our example, we knew that all uses of <code>x</code> would be initialized so it makes more sense to use definite assignment assertions than non-null assertions.</p>\n<h2 id=\"fixed-length-tuples\" style=\"position:relative;\"><a href=\"#fixed-length-tuples\" aria-label=\"fixed length tuples permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Fixed Length Tuples</h2>\n<p>In TypeScript 2.6 and earlier, <code>[number, string, string]</code> was considered a subtype of <code>[number, string]</code>.\nThis was motivated by TypeScript’s structural nature; the first and second elements of a <code>[number, string, string]</code> are respectively subtypes of the first and second elements of <code>[number, string]</code>.\nHowever, after examining real world usage of tuples, we noticed that most situations in which this was permitted was typically undesirable.</p>\n<p>In TypeScript 2.7, tuples of different arities are no longer assignable to each other.\nThanks to a pull request from <a href=\"https://github.com/tycho01\">Tycho Grouwstra</a>, tuple types now encode their arity into the type of their respective <code>length</code> property.\nThis is accomplished by leveraging numeric literal types, which now allow tuples to be distinct from tuples of different arities.</p>\n<p>Conceptually, you might consider the type <code>[number, string]</code> to be equivalent to the following declaration of <code>NumStrTuple</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> NumStrTuple </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Array&lt;number | string&gt; {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">: number;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">: string;</span>\n<span style=\"color: #000000\">  length: </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// using the numeric literal type '2'</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Note that this is a breaking change for some code.\nIf you need to resort to the original behavior in which tuples only enforce a minimum length, you can use a similar declaration that does not explicitly define a <code>length</code> property, falling back to <code>number</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> MinimumNumStrTuple </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Array&lt;number | string&gt; {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">: number;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">: string;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Note that this does not imply tuples represent immutable arrays, but it is an implied convention.</p>\n<h2 id=\"improved-type-inference-for-object-literals\" style=\"position:relative;\"><a href=\"#improved-type-inference-for-object-literals\" aria-label=\"improved type inference for object literals permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Improved type inference for object literals</h2>\n<p>TypeScript 2.7 improves type inference for multiple object literals occurring in the same context.\nWhen multiple object literal types contribute to a union type, we now <em>normalize</em> the object literal types such that all properties are present in each constituent of the union type.</p>\n<p>Consider:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> obj = test ? { text: </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\"> } : {}; </span><span style=\"color: #008000\">// { text: string } | { text?: undefined }</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> s = obj.text; </span><span style=\"color: #008000\">// string | undefined</span></code></div></pre>\n<p>Previously type <code>{}</code> was inferred for <code>obj</code> and the second line subsequently caused an error because <code>obj</code> would appear to have no properties.\nThat obviously wasn’t ideal.</p>\n<h4 id=\"example-26\" style=\"position:relative;\"><a href=\"#example-26\" aria-label=\"example 26 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// let obj: { a: number, b: number } |</span>\n<span style=\"color: #008000\">//     { a: string, b?: undefined } |</span>\n<span style=\"color: #008000\">//     { a?: undefined, b?: undefined }</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> obj = [{ a: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, b: </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\"> }, { a: </span><span style=\"color: #A31515\">\"abc\"</span><span style=\"color: #000000\"> }, {}][</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">];</span>\n<span style=\"color: #000000\">obj.a; </span><span style=\"color: #008000\">// string | number | undefined</span>\n<span style=\"color: #000000\">obj.b; </span><span style=\"color: #008000\">// number | undefined</span></code></div></pre>\n<p>Multiple object literal type inferences for the same type parameter are similarly collapsed into a single normalized union type:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f&lt;T&gt;(...items: T[]): T;</span>\n<span style=\"color: #008000\">// let obj: { a: number, b: number } |</span>\n<span style=\"color: #008000\">//     { a: string, b?: undefined } |</span>\n<span style=\"color: #008000\">//     { a?: undefined, b?: undefined }</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> obj = f({ a: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, b: </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\"> }, { a: </span><span style=\"color: #A31515\">\"abc\"</span><span style=\"color: #000000\"> }, {});</span>\n<span style=\"color: #000000\">obj.a; </span><span style=\"color: #008000\">// string | number | undefined</span>\n<span style=\"color: #000000\">obj.b; </span><span style=\"color: #008000\">// number | undefined</span></code></div></pre>\n<h2 id=\"improved-handling-of-structurally-identical-classes-and-instanceof-expressions\" style=\"position:relative;\"><a href=\"#improved-handling-of-structurally-identical-classes-and-instanceof-expressions\" aria-label=\"improved handling of structurally identical classes and instanceof expressions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Improved handling of structurally identical classes and <code>instanceof</code> expressions</h2>\n<p>TypeScript 2.7 improves the handling of structurally identical classes in union types and <code>instanceof</code> expressions:</p>\n<ul>\n<li>Structurally identical, but distinct, class types are now preserved in union types (instead of eliminating all but one).</li>\n<li>Union type subtype reduction only removes a class type if it is a subclass of <em>and</em> derives from another class type in the union.</li>\n<li>Type checking of the <code>instanceof</code> operator is now based on whether the type of the left operand <em>derives from</em> the type indicated by the right operand (as opposed to a structural subtype check).</li>\n</ul>\n<p>This means that union types and <code>instanceof</code> properly distinguish between structurally identical classes.</p>\n<h4 id=\"example-27\" style=\"position:relative;\"><a href=\"#example-27\" aria-label=\"example 27 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example:</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> A {}</span>\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> B </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> A {}</span>\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> A {}</span>\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> D </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> A {</span>\n<span style=\"color: #000000\">  c: string;</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> E </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> D {}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x1 = !</span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\"> ? </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> A() : </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> B(); </span><span style=\"color: #008000\">// A</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x2 = !</span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\"> ? </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> B() : </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> C(); </span><span style=\"color: #008000\">// B | C (previously B)</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x3 = !</span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\"> ? </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> C() : </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> D(); </span><span style=\"color: #008000\">// C | D (previously C)</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> a1 = [</span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> A(), </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> B(), </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> C(), </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> D(), </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> E()]; </span><span style=\"color: #008000\">// A[]</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> a2 = [</span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> B(), </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> C(), </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> D(), </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> E()]; </span><span style=\"color: #008000\">// (B | C | D)[] (previously B[])</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f1(x: B | C | D) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (x </span><span style=\"color: #0000FF\">instanceof</span><span style=\"color: #000000\"> B) {</span>\n<span style=\"color: #000000\">    x; </span><span style=\"color: #008000\">// B (previously B | D)</span>\n<span style=\"color: #000000\">  } </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (x </span><span style=\"color: #0000FF\">instanceof</span><span style=\"color: #000000\"> C) {</span>\n<span style=\"color: #000000\">    x; </span><span style=\"color: #008000\">// C</span>\n<span style=\"color: #000000\">  } </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    x; </span><span style=\"color: #008000\">// D (previously never)</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"type-guards-inferred-from-in-operator\" style=\"position:relative;\"><a href=\"#type-guards-inferred-from-in-operator\" aria-label=\"type guards inferred from in operator permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Type guards inferred from <code>in</code> operator</h2>\n<p>The <code>in</code> operator now acts as a narrowing expression for types.</p>\n<p>For a <code>n in x</code> expression, where <code>n</code> is a string literal or string literal type and <code>x</code> is a union type, the “true” branch narrows to types which have an optional or required property <code>n</code>, and the “false” branch narrows to types which have an optional or missing property <code>n</code>.</p>\n<h4 id=\"example-28\" style=\"position:relative;\"><a href=\"#example-28\" aria-label=\"example 28 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> A {</span>\n<span style=\"color: #000000\">  a: number;</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> B {</span>\n<span style=\"color: #000000\">  b: string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> foo(x: A | B) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #A31515\">\"a\"</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> x) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x.a;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x.b;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"support-for-import-d-from-cjs-form-commonjs-modules-with---esmoduleinterop\" style=\"position:relative;\"><a href=\"#support-for-import-d-from-cjs-form-commonjs-modules-with---esmoduleinterop\" aria-label=\"support for import d from cjs form commonjs modules with   esmoduleinterop permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for <code>import d from \"cjs\"</code> form CommonJS modules with <code>--esModuleInterop</code></h2>\n<p>TypeScript 2.7 updates CommonJS/AMD/UMD module emit to synthesize namespace records based on the presence of an <code>__esModule</code> indicator under <code>--esModuleInterop</code>.\nThe change brings the generated output from TypeScript closer to that generated by Babel.</p>\n<p>Previously CommonJS/AMD/UMD modules were treated in the same way as ES6 modules, resulting in a couple of problems. Namely:</p>\n<ul>\n<li>TypeScript treats a namespace import (i.e. <code>import * as foo from \"foo\"</code>) for a CommonJS/AMD/UMD module as equivalent to <code>const foo = require(\"foo\")</code>.\nThings are simple here, but they don’t work out if the primary object being imported is a primitive or a class or a function.\nECMAScript spec stipulates that a namespace record is a plain object, and that a namespace import (<code>foo</code> in the example above) is not callable, though allowed by TypeScript</li>\n<li>Similarly a default import (i.e. <code>import d from \"foo\"</code>) for a CommonJS/AMD/UMD module as equivalent to <code>const d = require(\"foo\").default</code>.\nMost of the CommonJS/AMD/UMD modules available today do not have a <code>default</code> export, making this import pattern practically unusable to import non-ES modules (i.e. CommonJS/AMD/UMD). For instance <code>import fs from \"fs\"</code> or <code>import express from \"express\"</code> are not allowed.</li>\n</ul>\n<p>Under the new <code>--esModuleInterop</code> these two issues should be addressed:</p>\n<ul>\n<li>A namespace import (i.e. <code>import * as foo from \"foo\"</code>) is now correctly flagged as uncallabale. Calling it will result in an error.</li>\n<li>Default imports to CommonJS/AMD/UMD are now allowed (e.g. <code>import fs from \"fs\"</code>), and should work as expected.</li>\n</ul>\n<blockquote>\n<p>Note: The new behavior is added under a flag to avoid unwarranted breaks to existing code bases. We highly recommend applying it both to new and existing projects.\nFor existing projects, namespace imports (<code>import * as express from \"express\"; express();</code>) will need to be converted to default imports (<code>import express from \"express\"; express();</code>).</p>\n</blockquote>\n<h4 id=\"example-29\" style=\"position:relative;\"><a href=\"#example-29\" aria-label=\"example 29 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<p>With <code>--esModuleInterop</code> two new helpers are generated <code>__importStar</code> and <code>__importDefault</code> for import <code>*</code> and import <code>default</code> respectively.\nFor instance input like:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">*</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> foo </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"foo\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> b </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"bar\"</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>Will generate:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #A31515\">\"use strict\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> __importStar =</span>\n<span style=\"color: #000000\">  (</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\"> && </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.__importStar) ||</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(mod) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (mod && mod.__esModule) </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> mod;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> result = {};</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (mod != </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">)</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> k </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> mod)</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];</span>\n<span style=\"color: #000000\">    result[</span><span style=\"color: #A31515\">\"default\"</span><span style=\"color: #000000\">] = mod;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> result;</span>\n<span style=\"color: #000000\">  };</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> __importDefault =</span>\n<span style=\"color: #000000\">  (</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\"> && </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.__importDefault) ||</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(mod) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> mod && mod.__esModule ? mod : { default: mod };</span>\n<span style=\"color: #000000\">  };</span>\n<span style=\"color: #000000\">exports.__esModule = </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> foo = __importStar(require(</span><span style=\"color: #A31515\">\"foo\"</span><span style=\"color: #000000\">));</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> bar_1 = __importDefault(require(</span><span style=\"color: #A31515\">\"bar\"</span><span style=\"color: #000000\">));</span></code></div></pre>\n<h2 id=\"numeric-separators\" style=\"position:relative;\"><a href=\"#numeric-separators\" aria-label=\"numeric separators permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Numeric separators</h2>\n<p>TypeScript 2.7 brings support for <a href=\"https://github.com/tc39/proposal-numeric-separator\">ES Numeric Separators</a>.\nNumeric literals can now be separated into segments using <code>_</code>.</p>\n<h5 id=\"example-30\" style=\"position:relative;\"><a href=\"#example-30\" aria-label=\"example 30 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> milion = 1_000_000;</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> phone = 555_734_2231;</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> bytes = 0xff_0c_00_ff;</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> word = 0b1100_0011_1101_0001;</span></code></div></pre>\n<h2 id=\"cleaner-output-in---watch-mode\" style=\"position:relative;\"><a href=\"#cleaner-output-in---watch-mode\" aria-label=\"cleaner output in   watch mode permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Cleaner output in <code>--watch</code> mode</h2>\n<p>TypeScript’s <code>--watch</code> mode now clears the screen after a re-compilation is requested.</p>\n<h2 id=\"prettier---pretty-output\" style=\"position:relative;\"><a href=\"#prettier---pretty-output\" aria-label=\"prettier   pretty output permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Prettier <code>--pretty</code> output</h2>\n<p>TypeScript’s <code>--pretty</code> flag can make error messages easier to read and manage.\n<code>--pretty</code> now uses colors for file names, diagnostic codes, and line numbers.\nFile names and positions are now also formatted to allow navigation in common terminals (e.g. Visual Studio Code terminal).</p>\n<h2 id=\"typescript-26\" style=\"position:relative;\"><a href=\"#typescript-26\" aria-label=\"typescript 26 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 2.6</h2>\n<h2 id=\"strict-function-types\" style=\"position:relative;\"><a href=\"#strict-function-types\" aria-label=\"strict function types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Strict function types</h2>\n<p>TypeScript 2.6 introduces a new strict checking flag, <code>--strictFunctionTypes</code>.\nThe <code>--strictFunctionTypes</code> switch is part of the <code>--strict</code> family of switches, meaning that it defaults to on in <code>--strict</code> mode.\nYou can opt-out by setting <code>--strictFunctionTypes false</code> on your command line or in your tsconfig.json.</p>\n<p>Under <code>--strictFunctionTypes</code> function type parameter positions are checked <em>contravariantly</em> instead of <em>bivariantly</em>.\nFor some background on what variance means for function types check out <a href=\"https://www.stephanboyer.com/post/132/what-are-covariance-and-contravariance\">What are covariance and contravariance?</a>.</p>\n<p>The stricter checking applies to all function types, <em>except</em> those originating in method or constructor declarations.\nMethods are excluded specifically to ensure generic classes and interfaces (such as <code>Array&#x3C;T></code>) continue to mostly relate covariantly.</p>\n<p>Consider the following example in which <code>Animal</code> is the supertype of <code>Dog</code> and <code>Cat</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> f1: (x: Animal) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> f2: (x: Dog) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> f3: (x: Cat) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void;</span>\n<span style=\"color: #000000\">f1 = f2; </span><span style=\"color: #008000\">// Error with --strictFunctionTypes</span>\n<span style=\"color: #000000\">f2 = f1; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">f2 = f3; </span><span style=\"color: #008000\">// Error</span></code></div></pre>\n<p>The first assignment is permitted in default type checking mode, but flagged as an error in strict function types mode.\nIntuitively, the default mode permits the assignment because it is <em>possibly</em> sound, whereas strict function types mode makes it an error because it isn’t <em>provably</em> sound.\nIn either mode the third assignment is an error because it is <em>never</em> sound.</p>\n<p>Another way to describe the example is that the type <code>(x: T) => void</code> is <em>bivariant</em> (i.e. covariant <em>or</em> contravariant) for <code>T</code> in default type checking mode, but <em>contravariant</em> for <code>T</code> in strict function types mode.</p>\n<h4 id=\"example-31\" style=\"position:relative;\"><a href=\"#example-31\" aria-label=\"example 31 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Comparer&lt;T&gt; {</span>\n<span style=\"color: #000000\">  compare: (a: T, b: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> animalComparer: Comparer&lt;Animal&gt;;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> dogComparer: Comparer&lt;Dog&gt;;</span>\n\n<span style=\"color: #000000\">animalComparer = dogComparer; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">dogComparer = animalComparer; </span><span style=\"color: #008000\">// Ok</span></code></div></pre>\n<p>The first assignment is now an error. Effectively, <code>T</code> is contravariant in <code>Comparer&#x3C;T></code> because it is used only in function type parameter positions.</p>\n<p>By the way, note that whereas some languages (e.g. C# and Scala) require variance annotations (<code>out</code>/<code>in</code> or <code>+</code>/<code>-</code>), variance emerges naturally from the actual use of a type parameter within a generic type due to TypeScript’s structural type system.</p>\n<h4 id=\"note\" style=\"position:relative;\"><a href=\"#note\" aria-label=\"note permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Note:</h4>\n<p>Under <code>--strictFunctionTypes</code> the first assignment is still permitted if <code>compare</code> was declared as a method.\nEffectively, <code>T</code> is bivariant in <code>Comparer&#x3C;T></code> because it is used only in method parameter positions.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Comparer&lt;T&gt; {</span>\n<span style=\"color: #000000\">  compare(a: T, b: T): number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> animalComparer: Comparer&lt;Animal&gt;;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> dogComparer: Comparer&lt;Dog&gt;;</span>\n\n<span style=\"color: #000000\">animalComparer = dogComparer; </span><span style=\"color: #008000\">// Ok because of bivariance</span>\n<span style=\"color: #000000\">dogComparer = animalComparer; </span><span style=\"color: #008000\">// Ok</span></code></div></pre>\n<p>TypeScript 2.6 also improves type inference involving contravariant positions:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> combine&lt;T&gt;(...funcs: ((x: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void)[]): (x: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> f </span><span style=\"color: #0000FF\">of</span><span style=\"color: #000000\"> funcs) f(x);</span>\n<span style=\"color: #000000\">  };</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> animalFunc(x: Animal) {}</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> dogFunc(x: Dog) {}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> combined = combine(animalFunc, dogFunc); </span><span style=\"color: #008000\">// (x: Dog) =&gt; void</span></code></div></pre>\n<p>Above, all inferences for <code>T</code> originate in contravariant positions, and we therefore infer the <em>best common subtype</em> for <code>T</code>.\nThis contrasts with inferences from covariant positions, where we infer the <em>best common supertype</em>.</p>\n<h2 id=\"support-for-jsx-fragment-syntax\" style=\"position:relative;\"><a href=\"#support-for-jsx-fragment-syntax\" aria-label=\"support for jsx fragment syntax permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for JSX Fragment Syntax</h2>\n<p>TypeScript 2.6.2 adds support for the new <code>&#x3C;>...&#x3C;/></code> syntax for fragments in JSX.\nIt is frequently desirable to return multiple children from a component.\nHowever, this is invalid, so the usual approach has been to wrap the text in an extra element, such as a <code>&#x3C;div></code> or <code>&#x3C;span></code> as shown below.</p>\n<pre class=\"shiki\"><div class=\"language-id\">tsx</div><div class='code-container'><code><span style=\"color: #000000\">render() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> (</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #800000\">&lt;div&gt;</span>\n<span style=\"color: #000000\">            Some text.</span>\n<span style=\"color: #000000\">            </span><span style=\"color: #800000\">&lt;h2&gt;</span><span style=\"color: #000000\">A heading</span><span style=\"color: #800000\">&lt;/h2&gt;</span>\n<span style=\"color: #000000\">            More text.</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #800000\">&lt;/div&gt;</span>\n<span style=\"color: #000000\">    );</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>To address this pattern, React introduced the <code>React.Fragment</code> component, which provides a dedicated way to wrap such elements without adding an element to the DOM.\nCorrespondingly, the <code>&#x3C;>...&#x3C;/></code> syntax was added to JSX to facilitate this new construct. Therefore, the above scenario becomes:</p>\n<pre class=\"shiki\"><div class=\"language-id\">tsx</div><div class='code-container'><code><span style=\"color: #000000\">render() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> (</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #CD3131\">&lt;&gt;</span>\n<span style=\"color: #000000\">            Some text.</span>\n<span style=\"color: #000000\">            </span><span style=\"color: #800000\">&lt;h2&gt;</span><span style=\"color: #000000\">A heading</span><span style=\"color: #800000\">&lt;/h2&gt;</span>\n<span style=\"color: #000000\">            More text.</span>\n<span style=\"color: #000000\">        &lt;/&gt;</span>\n<span style=\"color: #000000\">    );</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Under <code>--jsx preserve</code>, the new syntax is left untouched for TypeScript emit. Otherwise, for <code>--jsx react</code>, <code>&#x3C;>...&#x3C;/></code> is compiled to <code>React.createElement(React.Fragment, null, ...)</code>, where <code>React.createElement</code> respects <code>--jsxFactory</code>.\nNote that it is an error to use <code>&#x3C;>...&#x3C;/></code> when <code>--jsx react</code> and <code>--jsxFactory</code> are both enabled.</p>\n<p>Please refer to <a href=\"https://reactjs.org/blog/2017/11/28/react-v16.2.0-fragment-support.html\">the React blog</a> for more details on fragments and the new syntax.</p>\n<h2 id=\"cache-tagged-template-objects-in-modules\" style=\"position:relative;\"><a href=\"#cache-tagged-template-objects-in-modules\" aria-label=\"cache tagged template objects in modules permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Cache tagged template objects in modules</h2>\n<p>TypeScript 2.6 fixes the tagged string template emit to align better with the ECMAScript spec.\nAs per the <a href=\"https://tc39.github.io/ecma262/#sec-gettemplateobject\">ECMAScript spec</a>, every time a template tag is evaluated, the <em>same</em> template strings object (the same <code>TemplateStringsArray</code>) should be passed as the first argument.\nBefore TypeScript 2.6, the generated output was a completely new template object each time.\nThough the string contents are the same, this emit affects libraries that use the identity of the string for cache invalidation purposes, e.g. <a href=\"https://github.com/PolymerLabs/lit-html/issues/58\">lit-html</a>.</p>\n<h4 id=\"example-32\" style=\"position:relative;\"><a href=\"#example-32\" aria-label=\"example 32 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> id(x: TemplateStringsArray) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> templateObjectFactory() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">id`hello world`</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> result = templateObjectFactory() === templateObjectFactory(); </span><span style=\"color: #008000\">// true in TS 2.6</span></code></div></pre>\n<p>Results in the following generated code:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #A31515\">\"use strict\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> __makeTemplateObject =</span>\n<span style=\"color: #000000\">  (</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\"> && </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.__makeTemplateObject) ||</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(cooked, raw) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (Object.defineProperty) {</span>\n<span style=\"color: #000000\">      Object.defineProperty(cooked, </span><span style=\"color: #A31515\">\"raw\"</span><span style=\"color: #000000\">, { value: raw });</span>\n<span style=\"color: #000000\">    } </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">      cooked.raw = raw;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> cooked;</span>\n<span style=\"color: #000000\">  };</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> id(x) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> _a;</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> templateObjectFactory() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> id(</span>\n<span style=\"color: #000000\">    _a || (_a = __makeTemplateObject([</span><span style=\"color: #A31515\">\"hello world\"</span><span style=\"color: #000000\">], [</span><span style=\"color: #A31515\">\"hello world\"</span><span style=\"color: #000000\">]))</span>\n<span style=\"color: #000000\">  );</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> result = templateObjectFactory() === templateObjectFactory();</span></code></div></pre>\n<blockquote>\n<p>Note: This change brings a new emit helper, <code>__makeTemplateObject</code>;\nif you are using <code>--importHelpers</code> with <a href=\"https://github.com/Microsoft/tslib\"><code>tslib</code></a>, an updated to version 1.8 or later.</p>\n</blockquote>\n<h2 id=\"localized-diagnostics-on-the-command-line\" style=\"position:relative;\"><a href=\"#localized-diagnostics-on-the-command-line\" aria-label=\"localized diagnostics on the command line permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Localized diagnostics on the command line</h2>\n<p>TypeScript 2.6 npm package ships with localized versions of diagnostic messages for 13 languages.\nThe localized messages are available when using <code>--locale</code> flag on the command line.</p>\n<h4 id=\"example-33\" style=\"position:relative;\"><a href=\"#example-33\" aria-label=\"example 33 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<p>Error messages in Russian:</p>\n<pre class=\"shiki\"><div class=\"language-id\">sh</div><div class='code-container'><code><span style=\"color: #000000\">c:\\ts&gt;tsc --v</span>\n<span style=\"color: #000000\">Version 2.6.0-dev.20171003</span>\n\n<span style=\"color: #000000\">c:\\ts&gt;tsc --locale ru --pretty c:\\test\\a.ts</span>\n\n<span style=\"color: #000000\">../test/a.ts(1,5): error TS2322: Тип </span><span style=\"color: #A31515\">\"\"</span><span style=\"color: #000000\">string</span><span style=\"color: #A31515\">\"\"</span><span style=\"color: #000000\"> не может быть назначен для типа </span><span style=\"color: #A31515\">\"number\"</span><span style=\"color: #000000\">.</span>\n\n<span style=\"color: #000000\">1 var x: number = </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">      ~</span></code></div></pre>\n<p>And help in Japanese:</p>\n<pre class=\"shiki\"><div class=\"language-id\">sh</div><div class='code-container'><code><span style=\"color: #000000\">PS C:\\ts&gt; tsc --v</span>\n<span style=\"color: #000000\">Version 2.6.0-dev.20171003</span>\n\n<span style=\"color: #000000\">PS C:\\ts&gt; tsc --locale ja-jp</span>\n<span style=\"color: #000000\">バージョン 2.6.0-dev.20171003</span>\n<span style=\"color: #000000\">構文: tsc [オプション] [ファイル ...]</span>\n\n<span style=\"color: #000000\">例:  tsc hello.ts</span>\n<span style=\"color: #000000\">    tsc --outFile file.js file.ts</span>\n<span style=\"color: #000000\">    tsc @args.txt</span>\n\n<span style=\"color: #000000\">オプション:</span>\n<span style=\"color: #000000\"> -h, --help                                 このメッセージを表示します。</span>\n<span style=\"color: #000000\"> --all                                      コンパイラ オプションをすべて表示します。</span>\n<span style=\"color: #000000\"> -v, --version                              コンパイラのバージョンを表示します。</span>\n<span style=\"color: #000000\"> --init                                     TypeScript プロジェクトを初期化して、tsconfig.json ファイルを作成します。</span>\n<span style=\"color: #000000\"> -p ファイルまたはディレクトリ, --project ファイルまたはディレクトリ  構成ファイルか、</span><span style=\"color: #A31515\">'tsconfig.json'</span><span style=\"color: #000000\"> を含むフォルダーにパスが指定されたプロジェクトをコ</span>\n<span style=\"color: #000000\">ンパイルします。</span>\n<span style=\"color: #000000\"> --pretty                                   色とコンテキストを使用してエラーとメッセージにスタイルを適用します (試験的)。</span>\n<span style=\"color: #000000\"> -w, --watch                                入力ファイルを監視します。</span>\n<span style=\"color: #000000\"> -t バージョン, --target バージョン                   ECMAScript のターゲット バージョンを指定します: </span><span style=\"color: #A31515\">'ES3'</span><span style=\"color: #000000\"> (既定)、</span><span style=\"color: #A31515\">'ES5'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'ES2015'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'ES2016'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'ES2017'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'ES</span>\n<span style=\"color: #A31515\">NEXT'</span><span style=\"color: #000000\">。</span>\n<span style=\"color: #000000\"> -m 種類, --module 種類                         モジュール コード生成を指定します: </span><span style=\"color: #A31515\">'none'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'commonjs'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'amd'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'system'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'umd'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'es2015'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'ESNext'</span><span style=\"color: #000000\">。</span>\n<span style=\"color: #000000\"> --lib                                      コンパイルに含めるライブラリ ファイルを指定します:</span>\n<span style=\"color: #000000\">                                              </span><span style=\"color: #A31515\">'es5'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es6'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es7'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2016'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2017'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'esnext'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'dom'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'dom.iterable'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'webworker'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'scripthost'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es201</span>\n<span style=\"color: #A31515\">5.core'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015.collection'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015.generator'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015.iterable'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015.promise'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015.proxy'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015.reflect'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015.symbol'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015.symbol.wellkno</span>\n<span style=\"color: #A31515\">wn'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2016.array.include'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2017.object'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2017.sharedmemory'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2017.string'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2017.intl'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'esnext.asynciterable'</span>\n<span style=\"color: #000000\"> --allowJs                                  javascript ファイルのコンパイルを許可します。</span>\n<span style=\"color: #000000\"> --jsx 種類                                   JSX コード生成を指定します: </span><span style=\"color: #A31515\">'preserve'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'react-native'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'react'</span><span style=\"color: #000000\">。</span>\n<span style=\"color: #000000\"> -d, --declaration                          対応する </span><span style=\"color: #A31515\">'.d.ts'</span><span style=\"color: #000000\"> ファイルを生成します。</span>\n<span style=\"color: #000000\"> --sourceMap                                対応する </span><span style=\"color: #A31515\">'.map'</span><span style=\"color: #000000\"> ファイルを生成します。</span>\n<span style=\"color: #000000\"> --outFile ファイル                             出力を連結して 1 つのファイルを生成します。</span>\n<span style=\"color: #000000\"> --outDir ディレクトリ                            ディレクトリへ出力構造をリダイレクトします。</span>\n<span style=\"color: #000000\"> --removeComments                           コメントを出力しないでください。</span>\n<span style=\"color: #000000\"> --noEmit                                   出力しないでください。</span>\n<span style=\"color: #000000\"> --strict                                   strict 型チェックのオプションをすべて有効にします。</span>\n<span style=\"color: #000000\"> --noImplicitAny                            暗黙的な </span><span style=\"color: #A31515\">'any'</span><span style=\"color: #000000\"> 型を含む式と宣言に関するエラーを発生させます。</span>\n<span style=\"color: #000000\"> --strictNullChecks                         厳格な null チェックを有効にします。</span>\n<span style=\"color: #000000\"> --noImplicitThis                           暗黙的な </span><span style=\"color: #A31515\">'any'</span><span style=\"color: #000000\"> 型を持つ </span><span style=\"color: #A31515\">'this'</span><span style=\"color: #000000\"> 式でエラーが発生します。</span>\n<span style=\"color: #000000\"> --alwaysStrict                             厳格モードで解析してソース ファイルごとに </span><span style=\"color: #A31515\">\"use strict\"</span><span style=\"color: #000000\"> を生成します。</span>\n<span style=\"color: #000000\"> --noUnusedLocals                           使用されていないローカルに関するエラーを報告します。</span>\n<span style=\"color: #000000\"> --noUnusedParameters                       使用されていないパラメーターに関するエラーを報告します。</span>\n<span style=\"color: #000000\"> --noImplicitReturns                        関数の一部のコード パスが値を返さない場合にエラーを報告します。</span>\n<span style=\"color: #000000\"> --noFallthroughCasesInSwitch               switch ステートメントに </span><span style=\"color: #0000FF\">case</span><span style=\"color: #000000\"> のフォールスルーがある場合にエラーを報告します。</span>\n<span style=\"color: #000000\"> --types                                    コンパイルに含む型宣言ファイル。</span>\n<span style=\"color: #000000\"> @&lt;ファイル&gt;</span></code></div></pre>\n<h2 id=\"suppress-errors-in-ts-files-using--ts-ignore-comments\" style=\"position:relative;\"><a href=\"#suppress-errors-in-ts-files-using--ts-ignore-comments\" aria-label=\"suppress errors in ts files using  ts ignore comments permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Suppress errors in .ts files using ’// @ts-ignore’ comments</h2>\n<p>TypeScript 2.6 support suppressing errors in .js files using <code>// @ts-ignore</code> comments placed above the offending lines.</p>\n<h4 id=\"example-34\" style=\"position:relative;\"><a href=\"#example-34\" aria-label=\"example 34 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// @ts-ignore: Unreachable code error</span>\n<span style=\"color: #000000\">  console.log(</span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>A <code>// @ts-ignore</code> comment suppresses all errors that originate on the following line.\nIt is recommended practice to have the remainder of the comment following <code>@ts-ignore</code> explain which error is being suppressed.</p>\n<p>Please note that this comment only suppresses the error reporting, and we recommend you use this comments <em>very sparingly</em>.</p>\n<h2 id=\"faster-tsc---watch\" style=\"position:relative;\"><a href=\"#faster-tsc---watch\" aria-label=\"faster tsc   watch permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Faster <code>tsc --watch</code></h2>\n<p>TypeScript 2.6 brings a faster <code>--watch</code> implementation.\nThe new version optimizes code generation and checking for code bases using ES modules.\nChanges detected in a module file will result in <em>only</em> regenerating the changed module, and files that depend on it, instead of the whole project.\nProjects with large number of files should reap the most benefit from this change.</p>\n<p>The new implementation also brings performance enhancements to watching in tsserver.\nThe watcher logic has been completely rewritten to respond faster to change events.</p>\n<h2 id=\"write-only-references-now-flagged-as-unused\" style=\"position:relative;\"><a href=\"#write-only-references-now-flagged-as-unused\" aria-label=\"write only references now flagged as unused permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Write-only references now flagged as unused</h2>\n<p>TypeScript 2.6 adds revised implementation the <code>--noUnusedLocals</code> and <code>--noUnusedParameters</code> <a href=\"https://www.typescriptlang.org/docs/handbook/compiler-options.html\">compiler options</a>.\nDeclarations are only written to but never read from are now flagged as unused.</p>\n<h4 id=\"example-35\" style=\"position:relative;\"><a href=\"#example-35\" aria-label=\"example 35 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<p>Bellow both <code>n</code> and <code>m</code> will be marked as unused, because their values are never <em>read</em>. Previously TypeScript would only check whether their values were <em>referenced</em>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f(n: number) {</span>\n<span style=\"color: #000000\">  n = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">private</span><span style=\"color: #000000\"> m: number;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.m = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Also functions that are only called within their own bodies are considered unused.</p>\n<h4 id=\"example-36\" style=\"position:relative;\"><a href=\"#example-36\" aria-label=\"example 36 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f() {</span>\n<span style=\"color: #000000\">  f(); </span><span style=\"color: #008000\">// Error: 'f' is declared but its value is never read</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"typescript-25\" style=\"position:relative;\"><a href=\"#typescript-25\" aria-label=\"typescript 25 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 2.5</h2>\n<h2 id=\"optional-catch-clause-variables\" style=\"position:relative;\"><a href=\"#optional-catch-clause-variables\" aria-label=\"optional catch clause variables permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Optional <code>catch</code> clause variables</h2>\n<p>Thanks to work done by <a href=\"https://github.com/tinganho\">@tinganho</a>, TypeScript 2.5 implements a new ECMAScript feature that allows users to omit the variable in <code>catch</code> clauses.\nFor example, when using <code>JSON.parse</code> you may need to wrap calls to the function with a <code>try</code>/<code>catch</code>, but you may not end up using the <code>SyntaxError</code> that gets thrown when input is erroneous.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> input = </span><span style=\"color: #A31515\">\"...\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">try</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">  JSON.parse(input);</span>\n<span style=\"color: #000000\">} </span><span style=\"color: #0000FF\">catch</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// ^ Notice that our `catch` clause doesn't declare a variable.</span>\n<span style=\"color: #000000\">  console.log(</span><span style=\"color: #A31515\">\"Invalid JSON given\\n\\n\"</span><span style=\"color: #000000\"> + input);</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"type-assertioncast-syntax-in-checkjsts-check-mode\" style=\"position:relative;\"><a href=\"#type-assertioncast-syntax-in-checkjsts-check-mode\" aria-label=\"type assertioncast syntax in checkjsts check mode permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Type assertion/cast syntax in <code>checkJs</code>/<code>@ts-check</code> mode</h2>\n<p>TypeScript 2.5 introduces the ability to <a href=\"https://github.com/Microsoft/TypeScript/issues/5158\">assert the type of expressions when using plain JavaScript in your projects</a>.\nThe syntax is an <code>/** @type {...} */</code> annotation comment followed by a parenthesized expression whose type needs to be re-evaluated.\nFor example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x = </span><span style=\"color: #008000\">/** </span><span style=\"color: #0000FF\">@type</span><span style=\"color: #008000\"> {SomeType} */</span><span style=\"color: #000000\"> AnyParenthesizedExpression;</span></code></div></pre>\n<h2 id=\"deduplicated-and-redirected-packages\" style=\"position:relative;\"><a href=\"#deduplicated-and-redirected-packages\" aria-label=\"deduplicated and redirected packages permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Deduplicated and redirected packages</h2>\n<p>When importing using the <code>Node</code> module resolution strategy in TypeScript 2.5, the compiler will now check whether files originate from “identical” packages.\nIf a file originates from a package with a <code>package.json</code> containing the same <code>name</code> and <code>version</code> fields as a previously encountered package, then TypeScript will redirect itself to the top-most package.\nThis helps resolve problems where two packages might contain identical declarations of classes, but which contain <code>private</code> members that cause them to be structurally incompatible.</p>\n<p>As a nice bonus, this can also reduce the memory and runtime footprint of the compiler and language service by avoiding loading <code>.d.ts</code> files from duplicate packages.</p>\n<h2 id=\"the---preservesymlinks-compiler-flag\" style=\"position:relative;\"><a href=\"#the---preservesymlinks-compiler-flag\" aria-label=\"the   preservesymlinks compiler flag permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The <code>--preserveSymlinks</code> compiler flag</h2>\n<p>TypeScript 2.5 brings the <code>preserveSymlinks</code> flag, which parallels the behavior of <a href=\"https://nodejs.org/api/cli.html#cli_preserve_symlinks\">the <code>--preserve-symlinks</code> flag in Node.js</a>.\nThis flag also exhibits the opposite behavior to Webpack’s <code>resolve.symlinks</code> option (i.e. setting TypeScript’s <code>preserveSymlinks</code> to <code>true</code> parallels setting Webpack’s <code>resolve.symlinks</code> to <code>false</code>, and vice-versa).</p>\n<p>In this mode, references to modules and packages (e.g. <code>import</code>s and <code>/// &#x3C;reference type=\"...\" /></code> directives) are all resolved relative to the location of the symbolic link file, rather than relative to the path that the symbolic link resolves to.\nFor a more concrete example, we’ll defer to <a href=\"https://nodejs.org/api/cli.html#cli_preserve_symlinks\">the documentation on the Node.js website</a>.</p>\n<h2 id=\"typescript-24\" style=\"position:relative;\"><a href=\"#typescript-24\" aria-label=\"typescript 24 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 2.4</h2>\n<h2 id=\"dynamic-import-expressions\" style=\"position:relative;\"><a href=\"#dynamic-import-expressions\" aria-label=\"dynamic import expressions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Dynamic Import Expressions</h2>\n<p>Dynamic <code>import</code> expressions are a new feature and part of ECMAScript that allows users to asynchronously request a module at any arbitrary point in your program.</p>\n<p>This means that you can conditionally and lazily import other modules and libraries.\nFor example, here’s an <code>async</code> function that only imports a utility library when it’s needed:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> getZipFile(name: string, files: File[]): Promise&lt;File&gt; {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> zipUtil = </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> import(</span><span style=\"color: #A31515\">\"./utils/create-zip-file\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> zipContents = </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> zipUtil.getContentAsBlob(files);</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> File(zipContents, name);</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Many bundlers have support for automatically splitting output bundles based on these <code>import</code> expressions, so consider using this new feature with the <code>esnext</code> module target.</p>\n<h2 id=\"string-enums\" style=\"position:relative;\"><a href=\"#string-enums\" aria-label=\"string enums permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>String Enums</h2>\n<p>TypeScript 2.4 now allows enum members to contain string initializers.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">enum</span><span style=\"color: #000000\"> Colors {</span>\n<span style=\"color: #000000\">  Red = </span><span style=\"color: #A31515\">\"RED\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  Green = </span><span style=\"color: #A31515\">\"GREEN\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  Blue = </span><span style=\"color: #A31515\">\"BLUE\"</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>The caveat is that string-initialized enums can’t be reverse-mapped to get the original enum member name.\nIn other words, you can’t write <code>Colors[\"RED\"]</code> to get the string <code>\"Red\"</code>.</p>\n<h2 id=\"improved-inference-for-generics\" style=\"position:relative;\"><a href=\"#improved-inference-for-generics\" aria-label=\"improved inference for generics permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Improved inference for generics</h2>\n<p>TypeScript 2.4 introduces a few wonderful changes around the way generics are inferred.</p>\n<h3 id=\"return-types-as-inference-targets\" style=\"position:relative;\"><a href=\"#return-types-as-inference-targets\" aria-label=\"return types as inference targets permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Return types as inference targets</h3>\n<p>For one, TypeScript can now make inferences for the return type of a call.\nThis can improve your experience and catch errors.\nSomething that now works:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> arrayMap&lt;T, U&gt;(f: (x: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> U): (a: T[]) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> U[] {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> a </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> a.map(f);</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> lengths: (a: string[]) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> number[] = arrayMap(s </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> s.length);</span></code></div></pre>\n<p>As an example of new errors you might spot as a result:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: Promise&lt;string&gt; = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Promise(resolve </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">  resolve(</span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//      ~~ Error!</span>\n<span style=\"color: #000000\">});</span></code></div></pre>\n<h3 id=\"type-parameter-inference-from-contextual-types\" style=\"position:relative;\"><a href=\"#type-parameter-inference-from-contextual-types\" aria-label=\"type parameter inference from contextual types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Type parameter inference from contextual types</h3>\n<p>Prior to TypeScript 2.4, in the following example</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> f: &lt;T&gt;(x: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> T = y </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> y;</span></code></div></pre>\n<p><code>y</code> would have the type <code>any</code>.\nThis meant the program would type-check, but you could technically do anything with <code>y</code>, such as the following:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> f: &lt;T&gt;(x: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> T = y </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> y() + y.foo.bar;</span></code></div></pre>\n<p>That last example isn’t actually type-safe.</p>\n<p>In TypeScript 2.4, the function on the right side implicitly <em>gains</em> type parameters, and <code>y</code> is inferred to have the type of that type-parameter.</p>\n<p>If you use <code>y</code> in a way that the type parameter’s constraint doesn’t support, you’ll correctly get an error.\nIn this case, the constraint of <code>T</code> was (implicitly) <code>{}</code>, so the last example will appropriately fail.</p>\n<h3 id=\"stricter-checking-for-generic-functions\" style=\"position:relative;\"><a href=\"#stricter-checking-for-generic-functions\" aria-label=\"stricter checking for generic functions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Stricter checking for generic functions</h3>\n<p>TypeScript now tries to unify type parameters when comparing two single-signature types.\nAs a result, you’ll get stricter checks when relating two generic signatures, and may catch some bugs.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> A = &lt;T, U&gt;(x: T, y: U) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> [T, U];</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> B = &lt;S&gt;(x: S, y: S) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> [S, S];</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f(a: A, b: B) {</span>\n<span style=\"color: #000000\">  a = b; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">  b = a; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"strict-contravariance-for-callback-parameters\" style=\"position:relative;\"><a href=\"#strict-contravariance-for-callback-parameters\" aria-label=\"strict contravariance for callback parameters permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Strict contravariance for callback parameters</h2>\n<p>TypeScript has always compared parameters in a bivariant way.\nThere are a number of reasons for this, but by-and-large this was not been a huge issue for our users until we saw some of the adverse effects it had with <code>Promise</code>s and <code>Observable</code>s.</p>\n<p>TypeScript 2.4 introduces tightens this up when relating two callback types. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Mappable&lt;T&gt; {</span>\n<span style=\"color: #000000\">  map&lt;U&gt;(f: (x: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> U): Mappable&lt;U&gt;;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> a: Mappable&lt;number&gt;;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> b: Mappable&lt;string | number&gt;;</span>\n\n<span style=\"color: #000000\">a = b;</span>\n<span style=\"color: #000000\">b = a;</span></code></div></pre>\n<p>Prior to TypeScript 2.4, this example would succeed.\nWhen relating the types of <code>map</code>, TypeScript would bidirectionally relate their parameters (i.e. the type of <code>f</code>).\nWhen relating each <code>f</code>, TypeScript would also bidirectionally relate the type of <em>those</em> parameters.</p>\n<p>When relating the type of <code>map</code> in TS 2.4, the language will check whether each parameter is a callback type, and if so, it will ensure that those parameters are checked in a contravariant manner with respect to the current relation.</p>\n<p>In other words, TypeScript now catches the above bug, which may be a breaking change for some users, but will largely be helpful.</p>\n<h2 id=\"weak-type-detection\" style=\"position:relative;\"><a href=\"#weak-type-detection\" aria-label=\"weak type detection permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Weak Type Detection</h2>\n<p>TypeScript 2.4 introduces the concept of “weak types”.\nAny type that contains nothing but a set of all-optional properties is considered to be <em>weak</em>.\nFor example, this <code>Options</code> type is a weak type:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Options {</span>\n<span style=\"color: #000000\">  data?: string;</span>\n<span style=\"color: #000000\">  timeout?: number;</span>\n<span style=\"color: #000000\">  maxRetries?: number;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>In TypeScript 2.4, it’s now an error to assign anything to a weak type when there’s no overlap in properties.\nFor example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> sendMessage(options: Options) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// ...</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> opts = {</span>\n<span style=\"color: #000000\">  payload: </span><span style=\"color: #A31515\">\"hello world!\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  retryOnFail: </span><span style=\"color: #0000FF\">true</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #008000\">// Error!</span>\n<span style=\"color: #000000\">sendMessage(opts);</span>\n<span style=\"color: #008000\">// No overlap between the type of 'opts' and 'Options' itself.</span>\n<span style=\"color: #008000\">// Maybe we meant to use 'data'/'maxRetries' instead of 'payload'/'retryOnFail'.</span></code></div></pre>\n<p>You can think of this as TypeScript “toughening up” the weak guarantees of these types to catch what would otherwise be silent bugs.</p>\n<p>Since this is a breaking change, you may need to know about the workarounds which are the same as those for strict object literal checks:</p>\n<ol>\n<li>Declare the properties if they really do exist.</li>\n<li>Add an index signature to the weak type (i.e. <code>[propName: string]: {}</code>).</li>\n<li>Use a type assertion (i.e. <code>opts as Options</code>).</li>\n</ol>\n<h2 id=\"typescript-23\" style=\"position:relative;\"><a href=\"#typescript-23\" aria-label=\"typescript 23 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 2.3</h2>\n<h2 id=\"generators-and-iteration-for-es5es3\" style=\"position:relative;\"><a href=\"#generators-and-iteration-for-es5es3\" aria-label=\"generators and iteration for es5es3 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Generators and Iteration for ES5/ES3</h2>\n<p><em>First some ES2016 terminology:</em></p>\n<h4 id=\"iterators\" style=\"position:relative;\"><a href=\"#iterators\" aria-label=\"iterators permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Iterators</h4>\n<p><a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-iteration\">ES2015 introduced <code>Iterator</code></a>, which is an object that exposes three methods, <code>next</code>, <code>return</code>, and <code>throw</code>, as per the following interface:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Iterator&lt;T&gt; {</span>\n<span style=\"color: #000000\">  next(value?: any): IteratorResult&lt;T&gt;;</span>\n<span style=\"color: #000000\">  return?(value?: any): IteratorResult&lt;T&gt;;</span>\n<span style=\"color: #000000\">  throw?(e?: any): IteratorResult&lt;T&gt;;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>This kind of iterator is useful for iterating over synchronously available values, such as the elements of an Array or the keys of a Map.\nAn object that supports iteration is said to be “iterable” if it has a <code>Symbol.iterator</code> method that returns an <code>Iterator</code> object.</p>\n<p>The Iterator protocol also defines the target of some of the ES2015 features like <code>for..of</code> and spread operator and the array rest in destructuring assignmnets.</p>\n<h4 id=\"generators\" style=\"position:relative;\"><a href=\"#generators\" aria-label=\"generators permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Generators</h4>\n<p><a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-generatorfunction-objects\">ES2015 also introduced “Generators”</a>, which are functions that can be used to yield partial computation results via the <code>Iterator</code> interface and the <code>yield</code> keyword.\nGenerators can also internally delegate calls to another iterable through <code>yield *</code>. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function*</span><span style=\"color: #000000\"> f() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">yield</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">yield*</span><span style=\"color: #000000\"> [</span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">];</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h4 id=\"new---downleveliteration\" style=\"position:relative;\"><a href=\"#new---downleveliteration\" aria-label=\"new   downleveliteration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New <code>--downlevelIteration</code></h4>\n<p>Previously generators were only supported if the target is ES6/ES2015 or later.\nMoreover, constructs that operate on the Iterator protocol, e.g. <code>for..of</code> were only supported if they operate on arrays for targets below ES6/ES2015.</p>\n<p>TypeScript 2.3 adds full support for generators and the Iterator protocol for ES3 and ES5 targets with <code>--downlevelIteration</code> flag.</p>\n<p>With <code>--downlevelIteration</code>, the compiler uses new type check and emit behavior that attempts to call a <code>[Symbol.iterator]()</code> method on the iterated object if it is found, and creates a synthetic array iterator over the object if it is not.</p>\n<blockquote>\n<p>Please note that this requires a native <code>Symbol.iterator</code> or <code>Symbol.iterator</code> shim at runtime for any non-array values.</p>\n</blockquote>\n<p><code>for..of</code> statements, Array Destructuring, and Spread elements in Array, Call, and New expressions support <code>Symbol.iterator</code> in ES5/E3 if available when using <code>--downlevelIteration</code>, but can be used on an Array even if it does not define <code>Symbol.iterator</code> at run time or design time.</p>\n<h2 id=\"async-iteration\" style=\"position:relative;\"><a href=\"#async-iteration\" aria-label=\"async iteration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Async Iteration</h2>\n<p>TypeScript 2.3 adds support for the async iterators and generators as described by the current <a href=\"https://github.com/tc39/proposal-async-iteration\">TC39 proposal</a>.</p>\n<h4 id=\"async-iterators\" style=\"position:relative;\"><a href=\"#async-iterators\" aria-label=\"async iterators permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Async iterators</h4>\n<p>The Async Iteration introduces an <code>AsyncIterator</code>, which is similar to <code>Iterator</code>.\nThe difference lies in the fact that the <code>next</code>, <code>return</code>, and <code>throw</code> methods of an <code>AsyncIterator</code> return a <code>Promise</code> for the iteration result, rather than the result itself. This allows the caller to enlist in an asynchronous notification for the time at which the <code>AsyncIterator</code> has advanced to the point of yielding a value.\nAn <code>AsyncIterator</code> has the following shape:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> AsyncIterator&lt;T&gt; {</span>\n<span style=\"color: #000000\">  next(value?: any): Promise&lt;IteratorResult&lt;T&gt;&gt;;</span>\n<span style=\"color: #000000\">  return?(value?: any): Promise&lt;IteratorResult&lt;T&gt;&gt;;</span>\n<span style=\"color: #000000\">  throw?(e?: any): Promise&lt;IteratorResult&lt;T&gt;&gt;;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>An object that supports async iteration is said to be “iterable” if it has a <code>Symbol.asyncIterator</code> method that returns an <code>AsyncIterator</code> object.</p>\n<h4 id=\"async-generators\" style=\"position:relative;\"><a href=\"#async-generators\" aria-label=\"async generators permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Async Generators</h4>\n<p>The <a href=\"https://github.com/tc39/proposal-async-iteration\">Async Iteration proposal</a> introduces “Async Generators”, which are async functions that also can be used to yield partial computation results. Async Generators can also delegate calls via <code>yield*</code> to either an iterable or async iterable:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function*</span><span style=\"color: #000000\"> g() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">yield</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> sleep(</span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">yield*</span><span style=\"color: #000000\"> [</span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">];</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">yield*</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function*</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> sleep(</span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">yield</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">4</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  })();</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>As with Generators, Async Generators can only be function declarations, function expressions, or methods of classes or object literals. Arrow functions cannot be Async Generators. Async Generators require a valid, global <code>Promise</code> implementation (either native or an ES2015-compatible polyfill), in addition to a valid <code>Symbol.asyncIterator</code> reference (either a native symbol or a shim).</p>\n<h4 id=\"the-for-await-of-statement\" style=\"position:relative;\"><a href=\"#the-for-await-of-statement\" aria-label=\"the for await of statement permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The <code>for-await-of</code> Statement</h4>\n<p>Finally, ES2015 introduced the <code>for..of</code> statement as a means of iterating over an iterable.\nSimilarly, the Async Iteration proposal introduces the <code>for..await..of</code> statement to iterate over an async iterable:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f() {</span>\n<span style=\"color: #000000\">  for </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> (const x </span><span style=\"color: #0000FF\">of</span><span style=\"color: #000000\"> g()) {</span>\n<span style=\"color: #000000\">    console.log(x);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>The <code>for..await..of</code> statement is only legal within an Async Function or Async Generator.</p>\n<h4 id=\"caveats-6\" style=\"position:relative;\"><a href=\"#caveats-6\" aria-label=\"caveats 6 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Caveats</h4>\n<ul>\n<li>Keep in mind that our support for async iterators relies on support for <code>Symbol.asyncIterator</code> to exist at runtime.\nYou may need to polyfill <code>Symbol.asyncIterator</code>, which for simple purposes can be as simple as: <code>(Symbol as any).asyncIterator = Symbol.asyncIterator || Symbol.from(\"Symbol.asyncIterator\");</code></li>\n<li>You also need to include <code>esnext</code> in your <code>--lib</code> option, to get the <code>AsyncIterator</code> declaration if you do not already have it.</li>\n<li>Finally, if your target is ES5 or ES3, you’ll also need to set the <code>--downlevelIterators</code> flag.</li>\n</ul>\n<h2 id=\"generic-parameter-defaults\" style=\"position:relative;\"><a href=\"#generic-parameter-defaults\" aria-label=\"generic parameter defaults permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Generic parameter defaults</h2>\n<p>TypeScript 2.3 adds support for declaring defaults for generic type parameters.</p>\n<h4 id=\"example-37\" style=\"position:relative;\"><a href=\"#example-37\" aria-label=\"example 37 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<p>Consider a function that creates a new <code>HTMLElement</code>, calling it with no arguments generates a <code>Div</code>; you can optionally pass a list of children as well. Previously you would have to define it as:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> create(): Container&lt;HTMLDivElement, HTMLDivElement[]&gt;;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> create&lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> HTMLElement&gt;(element: T): Container&lt;T, T[]&gt;;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> create&lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> HTMLElement, U </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> HTMLElement&gt;(</span>\n<span style=\"color: #000000\">  element: T,</span>\n<span style=\"color: #000000\">  children: U[]</span>\n<span style=\"color: #000000\">): Container&lt;T, U[]&gt;;</span></code></div></pre>\n<p>With generic parameter defaults we can reduce it to:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> create&lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> HTMLElement = HTMLDivElement, U = T[]&gt;(</span>\n<span style=\"color: #000000\">  element?: T,</span>\n<span style=\"color: #000000\">  children?: U</span>\n<span style=\"color: #000000\">): Container&lt;T, U&gt;;</span></code></div></pre>\n<p>A generic parameter default follows the following rules:</p>\n<ul>\n<li>A type parameter is deemed optional if it has a default.</li>\n<li>Required type parameters must not follow optional type parameters.</li>\n<li>Default types for a type parameter must satisfy the constraint for the type parameter, if it exists.</li>\n<li>When specifying type arguments, you are only required to specify type arguments for the required type parameters. Unspecified type parameters will resolve to their default types.</li>\n<li>If a default type is specified and inference cannot chose a candidate, the default type is inferred.</li>\n<li>A class or interface declaration that merges with an existing class or interface declaration may introduce a default for an existing type parameter.</li>\n<li>A class or interface declaration that merges with an existing class or interface declaration may introduce a new type parameter as long as it specifies a default.</li>\n</ul>\n<h2 id=\"new---strict-master-option\" style=\"position:relative;\"><a href=\"#new---strict-master-option\" aria-label=\"new   strict master option permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New <code>--strict</code> master option</h2>\n<p>New checks added to TypeScript are often off by default to avoid breaking existing projects. While avoiding breakage is a good thing, this strategy has the drawback of making it increasingly complex to choose the highest level of type safety, and doing so requires explicit opt-in action on every TypeScript release. With the <code>--strict</code> option it becomes possible to choose maximum type safety with the understanding that additional errors might be reported by newer versions of the compiler as improved type checking features are added.</p>\n<p>The new <code>--strict</code> compiler option represents the recommended setting of a number of type checking options. Specifically, specifying <code>--strict</code> corresponds to specifying all of the following options (and may in the future include more options):</p>\n<ul>\n<li><code>--strictNullChecks</code></li>\n<li><code>--noImplicitAny</code></li>\n<li><code>--noImplicitThis</code></li>\n<li><code>--alwaysStrict</code></li>\n</ul>\n<p>In exact terms, the <code>--strict</code> option sets the <em>default</em> value for the compiler options listed above. This means it is still possible to individually control the options. For example,</p>\n<pre><code>--strict --noImplicitThis false\n</code></pre>\n<p>has the effect of turning on all strict options <em>except</em> the <code>--noImplicitThis</code> option. Using this scheme it is possible to express configurations consisting of <em>all</em> strict options except some explicitly listed options. In other words, it is now possible to default to the highest level of type safety but opt out of certain checks.</p>\n<p>Starting with TypeScript 2.3, the default <code>tsconfig.json</code> generated by <code>tsc --init</code> includes a <code>\"strict\": true</code> setting in the <code>\"compilerOptions\"</code> section. Thus, new projects started with <code>tsc --init</code> will by default have the highest level of type safety enabled.</p>\n<h2 id=\"enhanced---init-output\" style=\"position:relative;\"><a href=\"#enhanced---init-output\" aria-label=\"enhanced   init output permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Enhanced <code>--init</code> output</h2>\n<p>Along with setting <code>--strict</code> on by default, <code>tsc --init</code> has an enhanced output. Default <code>tsconfig.json</code> files generated by <code>tsc --init</code> now include a set of the common compiler options along with their descriptions commented out. Just un-comment the configuration you like to set to get the desired behavior; we hope the new output simplifies the setting up new projects and keeps configuration files readable as projects grow.</p>\n<h2 id=\"errors-in-js-files-with---checkjs\" style=\"position:relative;\"><a href=\"#errors-in-js-files-with---checkjs\" aria-label=\"errors in js files with   checkjs permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Errors in .js files with <code>--checkJs</code></h2>\n<p>By default the TypeScript compiler does not report any errors in .js files including using <code>--allowJs</code>. With TypeScript 2.3 type-checking errors can also be reported in <code>.js</code> files with <code>--checkJs</code>.</p>\n<p>You can skip checking some files by adding <code>// @ts-nocheck</code> comment to them; conversely you can choose to check only a few <code>.js</code> files by adding <code>// @ts-check</code> comment to them without setting <code>--checkJs</code>. You can also ignore errors on specific lines by adding <code>// @ts-ignore</code> on the preceding line.</p>\n<p><code>.js</code> files are still checked to ensure that they only include standard ECMAScript features; type annotations are only allowed in <code>.ts</code> files and are flagged as errors in <code>.js</code> files. JSDoc comments can be used to add some type information to your JavaScript code, see <a href=\"https://github.com/Microsoft/TypeScript/wiki/JSDoc-support-in-JavaScript\">JSDoc Support documentation</a> for more details about the supported JSDoc constructs.</p>\n<p>See <a href=\"https://github.com/Microsoft/TypeScript/wiki/Type-Checking-JavaScript-Files\">Type checking JavaScript Files documentation</a> for more details.</p>\n<h2 id=\"typescript-22\" style=\"position:relative;\"><a href=\"#typescript-22\" aria-label=\"typescript 22 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 2.2</h2>\n<h2 id=\"support-for-mix-in-classes\" style=\"position:relative;\"><a href=\"#support-for-mix-in-classes\" aria-label=\"support for mix in classes permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for Mix-in classes</h2>\n<p>TypeScript 2.2 adds support for the ECMAScript 2015 mixin class pattern (see <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#Mix-ins\">MDN Mixin description</a> and <a href=\"http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/\">“Real” Mixins with JavaScript Classes</a> for more details) as well as rules for combining mixin construct signatures with regular construct signatures in intersection types.</p>\n<h5 id=\"first-some-terminology\" style=\"position:relative;\"><a href=\"#first-some-terminology\" aria-label=\"first some terminology permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>First some terminology:</h5>\n<ul>\n<li>A <strong>mixin constructor type</strong> refers to a type that has a single construct signature with a single rest argument of type <code>any[]</code> and an object-like return type. For example, given an object-like type <code>X</code>, <code>new (...args: any[]) => X</code> is a mixin constructor type with an instance type <code>X</code>.</li>\n<li>A <strong>mixin class</strong> is a class declaration or expression that <code>extends</code> an expression of a type parameter type. The following rules apply to mixin class declarations:</li>\n<li>The type parameter type of the <code>extends</code> expression must be constrained to a mixin constructor type.</li>\n<li>The constructor of a mixin class (if any) must have a single rest parameter of type <code>any[]</code> and must use the spread operator to pass those parameters as arguments in a <code>super(...args)</code> call.</li>\n</ul>\n<p>Given an expression <code>Base</code> of a parametric type <code>T</code> with a constraint <code>X</code>, a mixin class <code>class C extends Base {...}</code> is processed as if <code>Base</code> had type <code>X</code> and the resulting type is the intersection <code>typeof C &#x26; T</code>. In other words, a mixin class is represented as an intersection between the mixin class constructor type and the parametric base class constructor type.</p>\n<p>When obtaining the construct signatures of an intersection type that contains mixin constructor types, the mixin construct signatures are discarded and their instance types are mixed into the return types of the other construct signatures in the intersection type. For example, the intersection type <code>{ new(...args: any[]) => A } &#x26; { new(s: string) => B }</code> has a single construct signature <code>new(s: string) => A &#x26; B</code>.</p>\n<h5 id=\"putting-all-of-the-above-rules-together-in-an-example\" style=\"position:relative;\"><a href=\"#putting-all-of-the-above-rules-together-in-an-example\" aria-label=\"putting all of the above rules together in an example permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Putting all of the above rules together in an example:</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Point {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(</span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> x: number, </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> y: number) {}</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Person {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(</span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> name: string) {}</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Constructor&lt;T&gt; = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> (...args: any[]) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> T;</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> Tagged&lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Constructor&lt;{}&gt;&gt;(Base: T) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Base {</span>\n<span style=\"color: #000000\">    _tag: string;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(...args: any[]) {</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0000FF\">super</span><span style=\"color: #000000\">(...args);</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">._tag = </span><span style=\"color: #A31515\">\"\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">  };</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> TaggedPoint = Tagged(Point);</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> point = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> TaggedPoint(</span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">20</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">point._tag = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Customer </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Tagged(Person) {</span>\n<span style=\"color: #000000\">  accountBalance: number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> customer = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Customer(</span><span style=\"color: #A31515\">\"Joe\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">customer._tag = </span><span style=\"color: #A31515\">\"test\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">customer.accountBalance = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>Mixin classes can constrain the types of classes they can mix into by specifying a construct signature return type in the constraint for the type parameter. For example, the following <code>WithLocation</code> function implements a subclass factory that adds a <code>getLocation</code> method to any class that satisfies the <code>Point</code> interface (i.e. that has <code>x</code> and <code>y</code> properties of type <code>number</code>).</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Point {</span>\n<span style=\"color: #000000\">  x: number;</span>\n<span style=\"color: #000000\">  y: number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> WithLocation = &lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Constructor&lt;Point&gt;&gt;(Base: T) </span><span style=\"color: #0000FF\">=&gt;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Base {</span>\n<span style=\"color: #000000\">    getLocation(): [number, number] {</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> [</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.x, </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.y];</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">  };</span></code></div></pre>\n<h2 id=\"object-type\" style=\"position:relative;\"><a href=\"#object-type\" aria-label=\"object type permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>object</code> type</h2>\n<p>TypeScript did not have a type that represents the non-primitive type, i.e. any thing that is not <code>number</code> | <code>string</code> | <code>boolean</code> | <code>symbol</code> | <code>null</code> | <code>undefined</code>. Enter the new <code>object</code> type.</p>\n<p>With <code>object</code> type, APIs like <code>Object.create</code> can be better represented. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> create(o: object | null): void;</span>\n\n<span style=\"color: #000000\">create({ prop: </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\"> }); </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #000000\">create(</span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// OK</span>\n\n<span style=\"color: #000000\">create(</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">create(</span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">create(</span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">create(</span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// Error</span></code></div></pre>\n<h2 id=\"support-for-newtarget\" style=\"position:relative;\"><a href=\"#support-for-newtarget\" aria-label=\"support for newtarget permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for <code>new.target</code></h2>\n<p>The <code>new.target</code> meta-property is new syntax introduced in ES2015. When an instance of a constructor is created via <code>new</code>, the value of <code>new.target</code> is set to be a reference to the constructor function initially used to allocate the instance. If a function is called rather than constructed via <code>new</code>, <code>new.target</code> is set to <code>undefined</code>.</p>\n<p><code>new.target</code> comes in handy when <code>Object.setPrototypeOf</code> or <code>__proto__</code> needs to be set in a class constructor. One such use case is inheriting from <code>Error</code> in NodeJS v4 and higher.</p>\n<h4 id=\"example-38\" style=\"position:relative;\"><a href=\"#example-38\" aria-label=\"example 38 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> CustomError </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Error {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(message?: string) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">super</span><span style=\"color: #000000\">(message); </span><span style=\"color: #008000\">// 'Error' breaks prototype chain here</span>\n<span style=\"color: #000000\">    Object.setPrototypeOf(</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\">.target.prototype); </span><span style=\"color: #008000\">// restore prototype chain</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>This results in the generated JS</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> CustomError = (</span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(_super) {</span>\n<span style=\"color: #000000\">  __extends(CustomError, _super);</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> CustomError() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> _newTarget = </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.constructor;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> _this = _super.apply(</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">arguments</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// 'Error' breaks prototype chain here</span>\n<span style=\"color: #000000\">    _this.__proto__ = _newTarget.prototype; </span><span style=\"color: #008000\">// restore prototype chain</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> _this;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> CustomError;</span>\n<span style=\"color: #000000\">})(Error);</span></code></div></pre>\n<p><code>new.target</code> also comes in handy for writing constructable functions, for example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\">.target) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">/* called via 'new' */</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Which translates to:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> _newTarget = </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\"> && </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">instanceof</span><span style=\"color: #000000\"> f ? </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.constructor : </span><span style=\"color: #0000FF\">void</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (_newTarget) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">/* called via 'new' */</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"better-checking-for-nullundefined-in-operands-of-expressions\" style=\"position:relative;\"><a href=\"#better-checking-for-nullundefined-in-operands-of-expressions\" aria-label=\"better checking for nullundefined in operands of expressions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Better checking for <code>null</code>/<code>undefined</code> in operands of expressions</h2>\n<p>TypeScript 2.2 improves checking of nullable operands in expressions. Specifically, these are now flagged as errors:</p>\n<ul>\n<li>If either operand of a <code>+</code> operator is nullable, and neither operand is of type <code>any</code> or <code>string</code>.</li>\n<li>If either operand of a <code>-</code>, <code>*</code>, <code>**</code>, <code>/</code>, <code>%</code>, <code>&#x3C;&#x3C;</code>, <code>>></code>, <code>>>></code>, <code>&#x26;</code>, <code>|</code>, or <code>^</code> operator is nullable.</li>\n<li>If either operand of a <code>&#x3C;</code>, <code>></code>, <code>&#x3C;=</code>, <code>>=</code>, or <code>in</code> operator is nullable.</li>\n<li>If the right operand of an <code>instanceof</code> operator is nullable.</li>\n<li>If the operand of a <code>+</code>, <code>-</code>, <code>~</code>, <code>++</code>, or <code>--</code> unary operator is nullable.</li>\n</ul>\n<p>An operand is considered nullable if the type of the operand is <code>null</code> or <code>undefined</code> or a union type that includes <code>null</code> or <code>undefined</code>. Note that the union type case only only occurs in <code>--strictNullChecks</code> mode because <code>null</code> and <code>undefined</code> disappear from unions in classic type checking mode.</p>\n<h2 id=\"dotted-property-for-types-with-string-index-signatures\" style=\"position:relative;\"><a href=\"#dotted-property-for-types-with-string-index-signatures\" aria-label=\"dotted property for types with string index signatures permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Dotted property for types with string index signatures</h2>\n<p>Types with a string index signature can be indexed using the <code>[]</code> notation, but were not allowed to use the <code>.</code>. Starting with TypeScript 2.2 using either should be allowed.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> StringMap&lt;T&gt; {</span>\n<span style=\"color: #000000\">  [x: string]: T;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> map: StringMap&lt;number&gt;;</span>\n\n<span style=\"color: #000000\">map[</span><span style=\"color: #A31515\">\"prop1\"</span><span style=\"color: #000000\">] = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">map.prop2 = </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>This only apply to types with an <em>explicit</em> string index signature. It is still an error to access unknown properties on a type using <code>.</code> notation.</p>\n<h2 id=\"support-for-spread-operator-on-jsx-element-children\" style=\"position:relative;\"><a href=\"#support-for-spread-operator-on-jsx-element-children\" aria-label=\"support for spread operator on jsx element children permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for spread operator on JSX element children</h2>\n<p>TypeScript 2.2 adds support for using spread on a JSX element children. Please see <a href=\"https://github.com/facebook/jsx/issues/57\">facebook/jsx#57</a> for more details.</p>\n<h4 id=\"example-39\" style=\"position:relative;\"><a href=\"#example-39\" aria-label=\"example 39 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> Todo(prop: { key: number; todo: string }) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> &lt;div&gt;{prop.key.toString() + prop.todo}&lt;/div&gt;;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> TodoList({ todos }: TodoListProps) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> (</span>\n<span style=\"color: #000000\">    &lt;div&gt;{...todos.map(todo </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> &lt;Todo key={todo.id} todo={todo.todo} /&gt;)}&lt;/div&gt;</span>\n<span style=\"color: #000000\">  );</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: TodoListProps;</span>\n\n<span style=\"color: #000000\">&lt;TodoList {...x} /&gt;;</span></code></div></pre>\n<h2 id=\"new-jsx-react-native\" style=\"position:relative;\"><a href=\"#new-jsx-react-native\" aria-label=\"new jsx react native permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New <code>jsx: react-native</code></h2>\n<p>React-native build pipeline expects all files to have a <code>.js</code> extensions even if the file contains JSX syntax. The new <code>--jsx</code> value <code>react-native</code> will persevere the JSX syntax in the output file, but give it a <code>.js</code> extension.</p>\n<h2 id=\"typescript-21\" style=\"position:relative;\"><a href=\"#typescript-21\" aria-label=\"typescript 21 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 2.1</h2>\n<h2 id=\"keyof-and-lookup-types\" style=\"position:relative;\"><a href=\"#keyof-and-lookup-types\" aria-label=\"keyof and lookup types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>keyof</code> and Lookup Types</h2>\n<p>In JavaScript it is fairly common to have APIs that expect property names as parameters, but so far it hasn’t been possible to express the type relationships that occur in those APIs.</p>\n<p>Enter Index Type Query or <code>keyof</code>;\nAn indexed type query <code>keyof T</code> yields the type of permitted property names for <code>T</code>.\nA <code>keyof T</code> type is considered a subtype of <code>string</code>.</p>\n<h5 id=\"example-40\" style=\"position:relative;\"><a href=\"#example-40\" aria-label=\"example 40 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Person {</span>\n<span style=\"color: #000000\">  name: string;</span>\n<span style=\"color: #000000\">  age: number;</span>\n<span style=\"color: #000000\">  location: string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> K1 = </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> Person; </span><span style=\"color: #008000\">// \"name\" | \"age\" | \"location\"</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> K2 = </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> Person[]; </span><span style=\"color: #008000\">// \"length\" | \"push\" | \"pop\" | \"concat\" | ...</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> K3 = </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> { [x: string]: Person }; </span><span style=\"color: #008000\">// string</span></code></div></pre>\n<p>The dual of this is <em>indexed access types</em>, also called <em>lookup types</em>.\nSyntactically, they look exactly like an element access, but are written as types:</p>\n<h5 id=\"example-41\" style=\"position:relative;\"><a href=\"#example-41\" aria-label=\"example 41 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> P1 = Person[</span><span style=\"color: #A31515\">\"name\"</span><span style=\"color: #000000\">]; </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> P2 = Person[</span><span style=\"color: #A31515\">\"name\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"age\"</span><span style=\"color: #000000\">]; </span><span style=\"color: #008000\">// string | number</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> P3 = string[</span><span style=\"color: #A31515\">\"charAt\"</span><span style=\"color: #000000\">]; </span><span style=\"color: #008000\">// (pos: number) =&gt; string</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> P4 = string[][</span><span style=\"color: #A31515\">\"push\"</span><span style=\"color: #000000\">]; </span><span style=\"color: #008000\">// (...items: string[]) =&gt; number</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> P5 = string[][</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">]; </span><span style=\"color: #008000\">// string</span></code></div></pre>\n<p>You can use this pattern with other parts of the type system to get type-safe lookups.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> getProperty&lt;T, K </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> T&gt;(obj: T, key: K) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> obj[key]; </span><span style=\"color: #008000\">// Inferred type is T[K]</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> setProperty&lt;T, K </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> T&gt;(obj: T, key: K, value: T[K]) {</span>\n<span style=\"color: #000000\">  obj[key] = value;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = { foo: </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">, bar: </span><span style=\"color: #A31515\">\"hello!\"</span><span style=\"color: #000000\"> };</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> foo = getProperty(x, </span><span style=\"color: #A31515\">\"foo\"</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// number</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> bar = getProperty(x, </span><span style=\"color: #A31515\">\"bar\"</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// string</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> oops = getProperty(x, </span><span style=\"color: #A31515\">\"wargarbl\"</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// Error! \"wargarbl\" is not \"foo\" | \"bar\"</span>\n\n<span style=\"color: #000000\">setProperty(x, </span><span style=\"color: #A31515\">\"foo\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// Error!, string expected number</span></code></div></pre>\n<h2 id=\"mapped-types\" style=\"position:relative;\"><a href=\"#mapped-types\" aria-label=\"mapped types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Mapped Types</h2>\n<p>One common task is to take an existing type and make each of its properties entirely optional.\nLet’s say we have a `Person:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Person {</span>\n<span style=\"color: #000000\">  name: string;</span>\n<span style=\"color: #000000\">  age: number;</span>\n<span style=\"color: #000000\">  location: string;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>A partial version of it would be:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> PartialPerson {</span>\n<span style=\"color: #000000\">  name?: string;</span>\n<span style=\"color: #000000\">  age?: number;</span>\n<span style=\"color: #000000\">  location?: string;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>with Mapped types, <code>PartialPerson</code> can be written as a generalized transformation on the type <code>Person</code> as:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Partial&lt;T&gt; = {</span>\n<span style=\"color: #000000\">  [P </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> keyof T]?: T[P];</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> PartialPerson = Partial&lt;Person&gt;;</span></code></div></pre>\n<p>Mapped types are produced by taking a union of literal types, and computing a set of properties for a new object type.\nThey’re like <a href=\"https://docs.python.org/2/tutorial/datastructures.html#nested-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 addition to <code>Partial</code>, Mapped Types can express many useful transformations on types:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Keep types the same, but make each property to be read-only.</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Readonly&lt;T&gt; = {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">readonly</span><span style=\"color: #000000\"> [P </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> keyof T]: T[P];</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #008000\">// Same property names, but make the value a promise instead of a concrete one</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Deferred&lt;T&gt; = {</span>\n<span style=\"color: #000000\">  [P </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> keyof T]: Promise&lt;T[P]&gt;;</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #008000\">// Wrap proxies around properties of T</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Proxify&lt;T&gt; = {</span>\n<span style=\"color: #000000\">  [P </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> keyof T]: { get(): T[P]; set(v: T[P]): void };</span>\n<span style=\"color: #000000\">};</span></code></div></pre>\n<h2 id=\"partial-readonly-record-and-pick\" style=\"position:relative;\"><a href=\"#partial-readonly-record-and-pick\" aria-label=\"partial readonly record and pick permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>Partial</code>, <code>Readonly</code>, <code>Record</code>, and <code>Pick</code></h2>\n<p><code>Partial</code> and <code>Readonly</code>, as described earlier, are very useful constructs.\nYou can use them to describe some common JS routines like:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> assign&lt;T&gt;(obj: T, props: Partial&lt;T&gt;): void;</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> freeze&lt;T&gt;(obj: T): Readonly&lt;T&gt;;</span></code></div></pre>\n<p>Because of that, they are now included by default in the standard library.</p>\n<p>We’re also including two other utility types as well: <code>Record</code> and <code>Pick</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// From T pick a set of properties K</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> pick&lt;T, K </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> T&gt;(obj: T, ...keys: K[]): Pick&lt;T, K&gt;;</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> nameAndAgeOnly = pick(person, </span><span style=\"color: #A31515\">\"name\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"age\"</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// { name: string, age: number }</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// For every properties K of type T, transform it to U</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> mapObject&lt;K </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> string, T, U&gt;(</span>\n<span style=\"color: #000000\">  obj: Record&lt;K, T&gt;,</span>\n<span style=\"color: #000000\">  f: (x: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> U</span>\n<span style=\"color: #000000\">): Record&lt;K, U&gt;;</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> names = { foo: </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, bar: </span><span style=\"color: #A31515\">\"world\"</span><span style=\"color: #000000\">, baz: </span><span style=\"color: #A31515\">\"bye\"</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> lengths = mapObject(names, s </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> s.length); </span><span style=\"color: #008000\">// { foo: number, bar: number, baz: number }</span></code></div></pre>\n<h2 id=\"object-spread-and-rest\" style=\"position:relative;\"><a href=\"#object-spread-and-rest\" aria-label=\"object spread and rest permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Object Spread and Rest</h2>\n<p>TypeScript 2.1 brings support for <a href=\"https://github.com/sebmarkbage/ecmascript-rest-spread\">ES2017 Spread and Rest</a>.</p>\n<p>Similar to array spread, spreading an object can be handy to get a shallow copy:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> copy = { ...original };</span></code></div></pre>\n<p>Similarly, you can merge several different objects.\nIn the following example, <code>merged</code> will have properties from <code>foo</code>, <code>bar</code>, and <code>baz</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> merged = { ...foo, ...bar, ...baz };</span></code></div></pre>\n<p>You can also override existing properties and add new ones:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> obj = { x: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, y: </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> newObj = { ...obj, z: </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">, y: </span><span style=\"color: #09835A\">4</span><span style=\"color: #000000\"> }; </span><span style=\"color: #008000\">// { x: number, y: number, z: number }</span></code></div></pre>\n<p>The order of specifying spread operations determines what properties end up in the resulting object;\nproperties in later spreads “win out” over previously created properties.</p>\n<p>Object rests are the dual of object spreads, in that they can extract any extra properties that don’t get picked up when destructuring an element:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> obj = { x: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, y: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, z: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> { z, ...obj1 } = obj;</span>\n<span style=\"color: #000000\">obj1; </span><span style=\"color: #008000\">// {x: number, y: number};</span></code></div></pre>\n<h2 id=\"downlevel-async-functions\" style=\"position:relative;\"><a href=\"#downlevel-async-functions\" aria-label=\"downlevel async functions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Downlevel Async Functions</h2>\n<p>This feature was supported before TypeScript 2.1, but only when targeting ES6/ES2015.\nTypeScript 2.1 brings the capability to ES3 and ES5 run-times, meaning you’ll be free to take advantage of it no matter what environment you’re using.</p>\n<blockquote>\n<p>Note: first, we need to make sure our run-time has an ECMAScript-compliant <code>Promise</code> available globally.\nThat might involve grabbing <a href=\"https://github.com/stefanpenner/es6-promise\">a polyfill</a> for <code>Promise</code>, or relying on one that you might have in the run-time that you’re targeting.\nWe also need to make sure that TypeScript knows <code>Promise</code> exists by setting your <code>lib</code> flag to something like <code>\"dom\", \"es2015\"</code> or <code>\"dom\", \"es2015.promise\", \"es5\"</code></p>\n</blockquote>\n<h5 id=\"example-42\" style=\"position:relative;\"><a href=\"#example-42\" aria-label=\"example 42 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<h5 id=\"tsconfigjson\" style=\"position:relative;\"><a href=\"#tsconfigjson\" aria-label=\"tsconfigjson permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>tsconfig.json</h5>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"compilerOptions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"lib\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"dom\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"es2015.promise\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"es5\"</span><span style=\"color: #000000\">]</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h5 id=\"dramaticwelcomets\" style=\"position:relative;\"><a href=\"#dramaticwelcomets\" aria-label=\"dramaticwelcomets permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>dramaticWelcome.ts</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> delay(milliseconds: number) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Promise&lt;void&gt;(resolve </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    setTimeout(resolve, milliseconds);</span>\n<span style=\"color: #000000\">  });</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> dramaticWelcome() {</span>\n<span style=\"color: #000000\">  console.log(</span><span style=\"color: #A31515\">\"Hello\"</span><span style=\"color: #000000\">);</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> i = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">; i &lt; </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">; i++) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> delay(</span><span style=\"color: #09835A\">500</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">    console.log(</span><span style=\"color: #A31515\">\".\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  }</span>\n\n<span style=\"color: #000000\">  console.log(</span><span style=\"color: #A31515\">\"World!\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #000000\">dramaticWelcome();</span></code></div></pre>\n<p>Compiling and running the output should result in the correct behavior on an ES3/ES5 engine.</p>\n<h2 id=\"support-for-external-helpers-library-tslib\" style=\"position:relative;\"><a href=\"#support-for-external-helpers-library-tslib\" aria-label=\"support for external helpers library tslib permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for external helpers library (<code>tslib</code>)</h2>\n<p>TypeScript injects a handful of helper functions such as <code>__extends</code> for inheritance, <code>__assign</code> for spread operator in object literals and JSX elements, and <code>__awaiter</code> for async functions.</p>\n<p>Previously there were two options:</p>\n<ol>\n<li>inject helpers in <em>every</em> file that needs them, or</li>\n<li>no helpers at all with <code>--noEmitHelpers</code>.</li>\n</ol>\n<p>The two options left more to be desired;\nbundling the helpers in every file was a pain point for customers trying to keep their package size small.\nAnd not including helpers, meant customers had to maintain their own helpers library.</p>\n<p>TypeScript 2.1 allows for including these files in your project once in a separate module, and the compiler will emit imports to them as needed.</p>\n<p>First, install the <a href=\"https://github.com/Microsoft/tslib\"><code>tslib</code></a> utility library:</p>\n<pre class=\"shiki\"><div class=\"language-id\">sh</div><div class='code-container'><code><span style=\"color: #000000\">npm install tslib</span></code></div></pre>\n<p>Second, compile your files using <code>--importHelpers</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">sh</div><div class='code-container'><code><span style=\"color: #000000\">tsc --module commonjs --importHelpers a.ts</span></code></div></pre>\n<p>So given the following input, the resulting <code>.js</code> file will include an import to <code>tslib</code> and use the <code>__assign</code> helper from it instead of inlining it.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> o = { a: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, name: </span><span style=\"color: #A31515\">\"o\"</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> copy = { ...o };</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #A31515\">\"use strict\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> tslib_1 = require(</span><span style=\"color: #A31515\">\"tslib\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">exports.o = { a: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, name: </span><span style=\"color: #A31515\">\"o\"</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #000000\">exports.copy = tslib_1.__assign({}, exports.o);</span></code></div></pre>\n<h2 id=\"untyped-imports\" style=\"position:relative;\"><a href=\"#untyped-imports\" aria-label=\"untyped imports permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Untyped imports</h2>\n<p>TypeScript has traditionally been overly strict about how you can import modules.\nThis was to avoid typos and prevent users from using modules incorrectly.</p>\n<p>However, a lot of the time, you might just want to import an existing module that may not have its own <code>.d.ts</code> file.\nPreviously this was an error.\nStarting with TypeScript 2.1 this is now much easier.</p>\n<p>With TypeScript 2.1, you can import a JavaScript module without needing a type declaration.\nA type declaration (such as <code>declare module \"foo\" { ... }</code> or <code>node_modules/@types/foo</code>) still takes priority if it exists.</p>\n<p>An import to a module with no declaration file will still be flagged as an error under <code>--noImplicitAny</code>.</p>\n<h5 id=\"example-43\" style=\"position:relative;\"><a href=\"#example-43\" aria-label=\"example 43 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Succeeds if `node_modules/asdf/index.js` exists, or if `node_modules/asdf/package.json` defines a valid \"main\" entry point</span>\n<span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> { x } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"asdf\"</span><span style=\"color: #000000\">;</span></code></div></pre>\n<h2 id=\"support-for---target-es2016---target-es2017-and---target-esnext\" style=\"position:relative;\"><a href=\"#support-for---target-es2016---target-es2017-and---target-esnext\" aria-label=\"support for   target es2016   target es2017 and   target esnext permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for <code>--target ES2016</code>, <code>--target ES2017</code> and <code>--target ESNext</code></h2>\n<p>TypeScript 2.1 supports three new target values <code>--target ES2016</code>, <code>--target ES2017</code> and <code>--target ESNext</code>.</p>\n<p>Using target <code>--target ES2016</code> will instruct the compiler not to transform ES2016-specific features, e.g. <code>**</code> operator.</p>\n<p>Similarly, <code>--target ES2017</code> will instruct the compiler not to transform ES2017-specific features like <code>async</code>/<code>await</code>.</p>\n<p><code>--target ESNext</code> targets latest supported <a href=\"https://github.com/tc39/proposals\">ES proposed features</a>.</p>\n<h2 id=\"improved-any-inference\" style=\"position:relative;\"><a href=\"#improved-any-inference\" aria-label=\"improved any inference permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Improved <code>any</code> Inference</h2>\n<p>Previously, if TypeScript couldn’t figure out the type of a variable, it would choose the <code>any</code> type.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x; </span><span style=\"color: #008000\">// implicitly 'any'</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> y = []; </span><span style=\"color: #008000\">// implicitly 'any[]'</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> z: any; </span><span style=\"color: #008000\">// explicitly 'any'.</span></code></div></pre>\n<p>With TypeScript 2.1, instead of just choosing <code>any</code>, TypeScript will infer types based on what you end up assigning later on.</p>\n<p>This is only enabled if <code>--noImplicitAny</code> is set.</p>\n<h5 id=\"example-44\" style=\"position:relative;\"><a href=\"#example-44\" aria-label=\"example 44 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x;</span>\n\n<span style=\"color: #008000\">// You can still assign anything you want to 'x'.</span>\n<span style=\"color: #000000\">x = () </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #008000\">// After that last assignment, TypeScript 2.1 knows that 'x' has type '() =&gt; number'.</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> y = x();</span>\n\n<span style=\"color: #008000\">// Thanks to that, it will now tell you that you can't add a number to a function!</span>\n<span style=\"color: #000000\">console.log(x + y);</span>\n<span style=\"color: #008000\">//          ~~~~~</span>\n<span style=\"color: #008000\">// Error! Operator '+' cannot be applied to types '() =&gt; number' and 'number'.</span>\n\n<span style=\"color: #008000\">// TypeScript still allows you to assign anything you want to 'x'.</span>\n<span style=\"color: #000000\">x = </span><span style=\"color: #A31515\">\"Hello world!\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #008000\">// But now it also knows that 'x' is a 'string'!</span>\n<span style=\"color: #000000\">x.toLowerCase();</span></code></div></pre>\n<p>The same sort of tracking is now also done for empty arrays.</p>\n<p>A variable declared with no type annotation and an initial value of <code>[]</code> is considered an implicit <code>any[]</code> variable.\nHowever, each subsequent <code>x.push(value)</code>, <code>x.unshift(value)</code> or <code>x[n] = value</code> operation <em>evolves</em> the type of the variable in accordance with what elements are added to it.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f1() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = [];</span>\n<span style=\"color: #000000\">  x.push(</span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  x[</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">] = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  x.unshift(</span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x; </span><span style=\"color: #008000\">// (string | number | boolean)[]</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f2() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (cond()) {</span>\n<span style=\"color: #000000\">    x = [];</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">while</span><span style=\"color: #000000\"> (cond()) {</span>\n<span style=\"color: #000000\">      x.push(</span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x; </span><span style=\"color: #008000\">// string[] | null</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"implicit-any-errors\" style=\"position:relative;\"><a href=\"#implicit-any-errors\" aria-label=\"implicit any errors permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Implicit any errors</h2>\n<p>One great benefit of this is that you’ll see <em>way fewer</em> implicit <code>any</code> errors when running with <code>--noImplicitAny</code>.\nImplicit <code>any</code> errors are only reported when the compiler is unable to know the type of a variable without a type annotation.</p>\n<h5 id=\"example-45\" style=\"position:relative;\"><a href=\"#example-45\" aria-label=\"example 45 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f3() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = []; </span><span style=\"color: #008000\">// Error: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined.</span>\n<span style=\"color: #000000\">  x.push(</span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> g() {</span>\n<span style=\"color: #000000\">    x; </span><span style=\"color: #008000\">// Error: Variable 'x' implicitly has an 'any[]' type.</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"better-inference-for-literal-types\" style=\"position:relative;\"><a href=\"#better-inference-for-literal-types\" aria-label=\"better inference for literal types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Better inference for literal types</h2>\n<p>String, numeric and boolean literal types (e.g. <code>\"abc\"</code>, <code>1</code>, and <code>true</code>) were previously inferred only in the presence of an explicit type annotation.\nStarting with TypeScript 2.1, literal types are <em>always</em> inferred for <code>const</code> variables and <code>readonly</code> properties.</p>\n<p>The type inferred for a <code>const</code> variable or <code>readonly</code> property without a type annotation is the type of the literal initializer.\nThe type inferred for a <code>let</code> variable, <code>var</code> variable, parameter, or non-<code>readonly</code> property with an initializer and no type annotation is the widened literal type of the initializer.\nWhere the widened type for a string literal type is <code>string</code>, <code>number</code> for numeric literal types, <code>boolean</code> for <code>true</code> or <code>false</code> and the containing enum for enum literal types.</p>\n<h5 id=\"example-46\" style=\"position:relative;\"><a href=\"#example-46\" aria-label=\"example 46 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> c1 = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Type 1</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> c2 = c1; </span><span style=\"color: #008000\">// Type 1</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> c3 = </span><span style=\"color: #A31515\">\"abc\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Type \"abc\"</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> c4 = </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Type true</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> c5 = cond ? </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> : </span><span style=\"color: #A31515\">\"abc\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Type 1 | \"abc\"</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v1 = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Type number</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v2 = c2; </span><span style=\"color: #008000\">// Type number</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v3 = c3; </span><span style=\"color: #008000\">// Type string</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v4 = c4; </span><span style=\"color: #008000\">// Type boolean</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v5 = c5; </span><span style=\"color: #008000\">// Type number | string</span></code></div></pre>\n<p>Literal type widening can be controlled through explicit type annotations.\nSpecifically, when an expression of a literal type is inferred for a const location without a type annotation, that <code>const</code> variable gets a widening literal type inferred.\nBut when a <code>const</code> location has an explicit literal type annotation, the <code>const</code> variable gets a non-widening literal type.</p>\n<h5 id=\"example-47\" style=\"position:relative;\"><a href=\"#example-47\" aria-label=\"example 47 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> c1 = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Widening type \"hello\"</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v1 = c1; </span><span style=\"color: #008000\">// Type string</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> c2: </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\"> = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Type \"hello\"</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v2 = c2; </span><span style=\"color: #008000\">// Type \"hello\"</span></code></div></pre>\n<h2 id=\"use-returned-values-from-super-calls-as-this\" style=\"position:relative;\"><a href=\"#use-returned-values-from-super-calls-as-this\" aria-label=\"use returned values from super calls as this permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Use returned values from super calls as ‘this’</h2>\n<p>In ES2015, constructors which return an object implicitly substitute the value of <code>this</code> for any callers of <code>super()</code>.\nAs a result, it is necessary to capture any potential return value of <code>super()</code> and replace it with <code>this</code>.\nThis change enables working with <a href=\"https://w3c.github.io/webcomponents/spec/custom/#htmlelement-constructor\">Custom Elements</a>, which takes advantage of this to initialize browser-allocated elements with user-written constructors.</p>\n<h5 id=\"example-48\" style=\"position:relative;\"><a href=\"#example-48\" aria-label=\"example 48 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Base {</span>\n<span style=\"color: #000000\">  x: number;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// return a new object other than `this`</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">      x: </span><span style=\"color: #09835A\">1</span>\n<span style=\"color: #000000\">    };</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Derived </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Base {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">super</span><span style=\"color: #000000\">();</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.x = </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Generates:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> Derived = (</span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(_super) {</span>\n<span style=\"color: #000000\">  __extends(Derived, _super);</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> Derived() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> _this = _super.call(</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">) || </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    _this.x = </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> _this;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> Derived;</span>\n<span style=\"color: #000000\">})(Base);</span></code></div></pre>\n<blockquote>\n<p>This change entails a break in the behavior of extending built-in classes like <code>Error</code>, <code>Array</code>, <code>Map</code>, etc.. Please see the <a href=\"https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\">extending built-ins breaking change documentation</a> for more details.</p>\n</blockquote>\n<h2 id=\"configuration-inheritance\" style=\"position:relative;\"><a href=\"#configuration-inheritance\" aria-label=\"configuration inheritance permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Configuration inheritance</h2>\n<p>Often a project has multiple output targets, e.g. <code>ES5</code> and <code>ES2015</code>, debug and production or <code>CommonJS</code> and <code>System</code>;\nJust a few configuration options change between these two targets, and maintaining multiple <code>tsconfig.json</code> files can be a hassle.</p>\n<p>TypeScript 2.1 supports inheriting configuration using <code>extends</code>, where:</p>\n<ul>\n<li><code>extends</code> is a new top-level property in <code>tsconfig.json</code> (alongside <code>compilerOptions</code>, <code>files</code>, <code>include</code>, and <code>exclude</code>).</li>\n<li>The value of <code>extends</code> must be a string containing a path to another configuration file to inherit from.</li>\n<li>The configuration from the base file are loaded first, then overridden by those in the inheriting config file.</li>\n<li>Circularity between configuration files is not allowed.</li>\n<li><code>files</code>, <code>include</code> and <code>exclude</code> from the inheriting config file <em>overwrite</em> those from the base config file.</li>\n<li>All relative paths found in the configuration file will be resolved relative to the configuration file they originated in.</li>\n</ul>\n<h5 id=\"example-49\" style=\"position:relative;\"><a href=\"#example-49\" aria-label=\"example 49 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<p><code>configs/base.json</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"compilerOptions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"noImplicitAny\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"strictNullChecks\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p><code>tsconfig.json</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"extends\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./configs/base\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"files\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"main.ts\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"supplemental.ts\"</span><span style=\"color: #000000\">]</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p><code>tsconfig.nostrictnull.json</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"extends\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./tsconfig\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"compilerOptions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"strictNullChecks\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">false</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"new---alwaysstrict\" style=\"position:relative;\"><a href=\"#new---alwaysstrict\" aria-label=\"new   alwaysstrict permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New <code>--alwaysStrict</code></h2>\n<p>Invoking the compiler with <code>--alwaysStrict</code> causes:</p>\n<ol>\n<li>Parses all the code in strict mode.</li>\n<li>Writes <code>\"use strict\";</code> directive atop every generated file.</li>\n</ol>\n<p>Modules are parsed automatically in strict mode.\nThe new flag is recommended for non-module code.</p>\n<h2 id=\"typescript-20\" style=\"position:relative;\"><a href=\"#typescript-20\" aria-label=\"typescript 20 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 2.0</h2>\n<h2 id=\"null--and-undefined-aware-types\" style=\"position:relative;\"><a href=\"#null--and-undefined-aware-types\" aria-label=\"null  and undefined aware types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Null- and undefined-aware types</h2>\n<p>TypeScript has two special types, Null and Undefined, that have the values <code>null</code> and <code>undefined</code> respectively.\nPreviously it was not possible to explicitly name these types, but <code>null</code> and <code>undefined</code> may now be used as type names regardless of type checking mode.</p>\n<p>The type checker previously considered <code>null</code> and <code>undefined</code> assignable to anything.\nEffectively, <code>null</code> and <code>undefined</code> were valid values of <em>every</em> type and it wasn’t possible to specifically exclude them (and therefore not possible to detect erroneous use of them).</p>\n<h3 id=\"--strictnullchecks\" style=\"position:relative;\"><a href=\"#--strictnullchecks\" aria-label=\"  strictnullchecks permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>--strictNullChecks</code></h3>\n<p><code>--strictNullChecks</code> switches to a new strict null checking mode.</p>\n<p>In strict null checking mode, the <code>null</code> and <code>undefined</code> values are <em>not</em> in the domain of every type and are only assignable to themselves and <code>any</code> (the one exception being that <code>undefined</code> is also assignable to <code>void</code>).\nSo, whereas <code>T</code> and <code>T | undefined</code> are considered synonymous in regular type checking mode (because <code>undefined</code> is considered a subtype of any <code>T</code>), they are different types in strict type checking mode, and only <code>T | undefined</code> permits <code>undefined</code> values. The same is true for the relationship of <code>T</code> to <code>T | null</code>.</p>\n<h4 id=\"example-50\" style=\"position:relative;\"><a href=\"#example-50\" aria-label=\"example 50 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Compiled with --strictNullChecks</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: number;</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> y: number | undefined;</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> z: number | null | undefined;</span>\n<span style=\"color: #000000\">x = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">y = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">z = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">x = </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">y = </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">z = </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">x = </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">y = </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">z = </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">x = y; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">x = z; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">y = x; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">y = z; </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">z = x; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">z = y; </span><span style=\"color: #008000\">// Ok</span></code></div></pre>\n<h3 id=\"assigned-before-use-checking\" style=\"position:relative;\"><a href=\"#assigned-before-use-checking\" aria-label=\"assigned before use checking permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Assigned-before-use checking</h3>\n<p>In strict null checking mode the compiler requires every reference to a local variable of a type that doesn’t include <code>undefined</code> to be preceded by an assignment to that variable in every possible preceding code path.</p>\n<h4 id=\"example-51\" style=\"position:relative;\"><a href=\"#example-51\" aria-label=\"example 51 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Compiled with --strictNullChecks</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: number;</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> y: number | null;</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> z: number | undefined;</span>\n<span style=\"color: #000000\">x; </span><span style=\"color: #008000\">// Error, reference not preceded by assignment</span>\n<span style=\"color: #000000\">y; </span><span style=\"color: #008000\">// Error, reference not preceded by assignment</span>\n<span style=\"color: #000000\">z; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">x = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">y = </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">x; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">y; </span><span style=\"color: #008000\">// Ok</span></code></div></pre>\n<p>The compiler checks that variables are definitely assigned by performing <em>control flow based type analysis</em>. See later for further details on this topic.</p>\n<h3 id=\"optional-parameters-and-properties\" style=\"position:relative;\"><a href=\"#optional-parameters-and-properties\" aria-label=\"optional parameters and properties permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Optional parameters and properties</h3>\n<p>Optional parameters and properties automatically have <code>undefined</code> added to their types, even when their type annotations don’t specifically include <code>undefined</code>.\nFor example, the following two types are identical:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Compiled with --strictNullChecks</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T1 = (x?: number) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> string; </span><span style=\"color: #008000\">// x has type number | undefined</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T2 = (x?: number | undefined) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> string; </span><span style=\"color: #008000\">// x has type number | undefined</span></code></div></pre>\n<h3 id=\"non-null-and-non-undefined-type-guards\" style=\"position:relative;\"><a href=\"#non-null-and-non-undefined-type-guards\" aria-label=\"non null and non undefined type guards permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Non-null and non-undefined type guards</h3>\n<p>A property access or a function call produces a compile-time error if the object or function is of a type that includes <code>null</code> or <code>undefined</code>.\nHowever, type guards are extended to support non-null and non-undefined checks.</p>\n<h4 id=\"example-52\" style=\"position:relative;\"><a href=\"#example-52\" aria-label=\"example 52 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Compiled with --strictNullChecks</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f(x: number): string;</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: number | null | undefined;</span>\n<span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (x) {</span>\n<span style=\"color: #000000\">  f(x); </span><span style=\"color: #008000\">// Ok, type of x is number here</span>\n<span style=\"color: #000000\">} </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">  f(x); </span><span style=\"color: #008000\">// Error, type of x is number? here</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> a = x != </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\"> ? f(x) : </span><span style=\"color: #A31515\">\"\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Type of a is string</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> b = x && f(x); </span><span style=\"color: #008000\">// Type of b is string | 0 | null | undefined</span></code></div></pre>\n<p>Non-null and non-undefined type guards may use the <code>==</code>, <code>!=</code>, <code>===</code>, or <code>!==</code> operator to compare to <code>null</code> or <code>undefined</code>, as in <code>x != null</code> or <code>x === undefined</code>.\nThe effects on subject variable types accurately reflect JavaScript semantics (e.g. double-equals operators check for both values no matter which one is specified whereas triple-equals only checks for the specified value).</p>\n<h3 id=\"dotted-names-in-type-guards\" style=\"position:relative;\"><a href=\"#dotted-names-in-type-guards\" aria-label=\"dotted names in type guards permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Dotted names in type guards</h3>\n<p>Type guards previously only supported checking local variables and parameters.\nType guards now support checking “dotted names” consisting of a variable or parameter name followed one or more property accesses.</p>\n<h4 id=\"example-53\" style=\"position:relative;\"><a href=\"#example-53\" aria-label=\"example 53 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Options {</span>\n<span style=\"color: #000000\">  location?: {</span>\n<span style=\"color: #000000\">    x?: number;</span>\n<span style=\"color: #000000\">    y?: number;</span>\n<span style=\"color: #000000\">  };</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> foo(options?: Options) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (options && options.location && options.location.x) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> x = options.location.x; </span><span style=\"color: #008000\">// Type of x is number</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Type guards for dotted names also work with user defined type guard functions and the <code>typeof</code> and <code>instanceof</code> operators and do not depend on the <code>--strictNullChecks</code> compiler option.</p>\n<p>A type guard for a dotted name has no effect following an assignment to any part of the dotted name.\nFor example, a type guard for <code>x.y.z</code> will have no effect following an assignment to <code>x</code>, <code>x.y</code>, or <code>x.y.z</code>.</p>\n<h3 id=\"expression-operators\" style=\"position:relative;\"><a href=\"#expression-operators\" aria-label=\"expression operators permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Expression operators</h3>\n<p>Expression operators permit operand types to include <code>null</code> and/or <code>undefined</code> but always produce values of non-null and non-undefined types.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Compiled with --strictNullChecks</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> sum(a: number | null, b: number | null) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> a + b; </span><span style=\"color: #008000\">// Produces value of type number</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>The <code>&#x26;&#x26;</code> operator adds <code>null</code> and/or <code>undefined</code> to the type of the right operand depending on which are present in the type of the left operand, and the <code>||</code> operator removes both <code>null</code> and <code>undefined</code> from the type of the left operand in the resulting union type.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Compiled with --strictNullChecks</span>\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Entity {</span>\n<span style=\"color: #000000\">  name: string;</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: Entity | null;</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> s = x && x.name; </span><span style=\"color: #008000\">// s is of type string | null</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> y = x || { name: </span><span style=\"color: #A31515\">\"test\"</span><span style=\"color: #000000\"> }; </span><span style=\"color: #008000\">// y is of type Entity</span></code></div></pre>\n<h3 id=\"type-widening\" style=\"position:relative;\"><a href=\"#type-widening\" aria-label=\"type widening permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Type widening</h3>\n<p>The <code>null</code> and <code>undefined</code> types are <em>not</em> widened to <code>any</code> in strict null checking mode.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> z = </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Type of z is null</span></code></div></pre>\n<p>In regular type checking mode the inferred type of <code>z</code> is <code>any</code> because of widening, but in strict null checking mode the inferred type of <code>z</code> is <code>null</code> (and therefore, absent a type annotation, <code>null</code> is the only possible value for <code>z</code>).</p>\n<h3 id=\"non-null-assertion-operator\" style=\"position:relative;\"><a href=\"#non-null-assertion-operator\" aria-label=\"non null assertion operator permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Non-null assertion operator</h3>\n<p>A new <code>!</code> post-fix expression operator may be used to assert that its operand is non-null and non-undefined in contexts where the type checker is unable to conclude that fact.\nSpecifically, the operation <code>x!</code> produces a value of the type of <code>x</code> with <code>null</code> and <code>undefined</code> excluded.\nSimilar to type assertions of the forms <code>&#x3C;T>x</code> and <code>x as T</code>, the <code>!</code> non-null assertion operator is simply removed in the emitted JavaScript code.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Compiled with --strictNullChecks</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> validateEntity(e?: Entity) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Throw exception if e is null or invalid entity</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> processEntity(e?: Entity) {</span>\n<span style=\"color: #000000\">  validateEntity(e);</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> s = e!.name; </span><span style=\"color: #008000\">// Assert that e is non-null and access name</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h3 id=\"compatibility\" style=\"position:relative;\"><a href=\"#compatibility\" aria-label=\"compatibility permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Compatibility</h3>\n<p>The new features are designed such that they can be used in both strict null checking mode and regular type checking mode.\nIn particular, the <code>null</code> and <code>undefined</code> types are automatically erased from union types in regular type checking mode (because they are subtypes of all other types), and the <code>!</code> non-null assertion expression operator is permitted but has no effect in regular type checking mode. Thus, declaration files that are updated to use null- and undefined-aware types can still be used in regular type checking mode for backwards compatibility.</p>\n<p>In practical terms, strict null checking mode requires that all files in a compilation are null- and undefined-aware.</p>\n<h2 id=\"control-flow-based-type-analysis\" style=\"position:relative;\"><a href=\"#control-flow-based-type-analysis\" aria-label=\"control flow based type analysis permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Control flow based type analysis</h2>\n<p>TypeScript 2.0 implements a control flow-based type analysis for local variables and parameters.\nPreviously, the type analysis performed for type guards was limited to <code>if</code> statements and <code>?:</code> conditional expressions and didn’t include effects of assignments and control flow constructs such as <code>return</code> and <code>break</code> statements.\nWith TypeScript 2.0, the type checker analyses all possible flows of control in statements and expressions to produce the most specific type possible (the <em>narrowed type</em>) at any given location for a local variable or parameter that is declared to have a union type.</p>\n<h4 id=\"example-54\" style=\"position:relative;\"><a href=\"#example-54\" aria-label=\"example 54 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> foo(x: string | number | boolean) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> x === </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    x; </span><span style=\"color: #008000\">// type of x is string here</span>\n<span style=\"color: #000000\">    x = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    x; </span><span style=\"color: #008000\">// type of x is number here</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  x; </span><span style=\"color: #008000\">// type of x is number | boolean here</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> bar(x: string | number) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> x === </span><span style=\"color: #A31515\">\"number\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  x; </span><span style=\"color: #008000\">// type of x is string here</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Control flow based type analysis is particuarly relevant in <code>--strictNullChecks</code> mode because nullable types are represented using union types:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> test(x: string | null) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (x === </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  x; </span><span style=\"color: #008000\">// type of x is string in remainder of function</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Furthermore, in <code>--strictNullChecks</code> mode, control flow based type analysis includes <em>definite assignment analysis</em> for local variables of types that don’t permit the value <code>undefined</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> mumble(check: boolean) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: number; </span><span style=\"color: #008000\">// Type doesn't permit undefined</span>\n<span style=\"color: #000000\">  x; </span><span style=\"color: #008000\">// Error, x is undefined</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (check) {</span>\n<span style=\"color: #000000\">    x = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    x; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  x; </span><span style=\"color: #008000\">// Error, x is possibly undefined</span>\n<span style=\"color: #000000\">  x = </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  x; </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"tagged-union-types\" style=\"position:relative;\"><a href=\"#tagged-union-types\" aria-label=\"tagged union types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Tagged union types</h2>\n<p>TypeScript 2.0 implements support for tagged (or discriminated) union types.\nSpecifically, the TS compiler now support type guards that narrow union types based on tests of a discriminant property and furthermore extend that capability to <code>switch</code> statements.</p>\n<h4 id=\"example-55\" style=\"position:relative;\"><a href=\"#example-55\" aria-label=\"example 55 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Square {</span>\n<span style=\"color: #000000\">  kind: </span><span style=\"color: #A31515\">\"square\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  size: number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Rectangle {</span>\n<span style=\"color: #000000\">  kind: </span><span style=\"color: #A31515\">\"rectangle\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  width: number;</span>\n<span style=\"color: #000000\">  height: number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Circle {</span>\n<span style=\"color: #000000\">  kind: </span><span style=\"color: #A31515\">\"circle\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  radius: number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Shape = Square | Rectangle | Circle;</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> area(s: Shape) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// In the following switch statement, the type of s is narrowed in each case clause</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// according to the value of the discriminant property, thus allowing the other properties</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// of that variant to be accessed without a type assertion.</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">switch</span><span style=\"color: #000000\"> (s.kind) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">case</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"square\"</span><span style=\"color: #000000\">:</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> s.size * s.size;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">case</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"rectangle\"</span><span style=\"color: #000000\">:</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> s.width * s.height;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">case</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"circle\"</span><span style=\"color: #000000\">:</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> Math.PI * s.radius * s.radius;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> test1(s: Shape) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (s.kind === </span><span style=\"color: #A31515\">\"square\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    s; </span><span style=\"color: #008000\">// Square</span>\n<span style=\"color: #000000\">  } </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    s; </span><span style=\"color: #008000\">// Rectangle | Circle</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> test2(s: Shape) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (s.kind === </span><span style=\"color: #A31515\">\"square\"</span><span style=\"color: #000000\"> || s.kind === </span><span style=\"color: #A31515\">\"rectangle\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  s; </span><span style=\"color: #008000\">// Circle</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>A <em>discriminant property type guard</em> is an expression of the form <code>x.p == v</code>, <code>x.p === v</code>, <code>x.p != v</code>, or <code>x.p !== v</code>, where <code>p</code> and <code>v</code> are a property and an expression of a string literal type or a union of string literal types.\nThe discriminant property type guard narrows the type of <code>x</code> to those constituent types of <code>x</code> that have a discriminant property <code>p</code> with one of the possible values of <code>v</code>.</p>\n<p>Note that we currently only support discriminant properties of string literal types.\nWe intend to later add support for boolean and numeric literal types.</p>\n<h2 id=\"the-never-type\" style=\"position:relative;\"><a href=\"#the-never-type\" aria-label=\"the never type permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The <code>never</code> type</h2>\n<p>TypeScript 2.0 introduces a new primitive type <code>never</code>.\nThe <code>never</code> type represents the type of values that never occur.\nSpecifically, <code>never</code> is the return type for functions that never return and <code>never</code> is the type of variables under type guards that are never true.</p>\n<p>The <code>never</code> type has the following characteristics:</p>\n<ul>\n<li><code>never</code> is a subtype of and assignable to every type.</li>\n<li>No type is a subtype of or assignable to <code>never</code> (except <code>never</code> itself).</li>\n<li>In a function expression or arrow function with no return type annotation, if the function has no <code>return</code> statements, or only <code>return</code> statements with expressions of type <code>never</code>, and if the end point of the function is not reachable (as determined by control flow analysis), the inferred return type for the function is <code>never</code>.</li>\n<li>In a function with an explicit <code>never</code> return type annotation, all <code>return</code> statements (if any) must have expressions of type <code>never</code> and the end point of the function must not be reachable.</li>\n</ul>\n<p>Because <code>never</code> is a subtype of every type, it is always omitted from union types and it is ignored in function return type inference as long as there are other types being returned.</p>\n<p>Some examples of functions returning <code>never</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Function returning never must have unreachable end point</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> error(message: string): never {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">throw</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Error(message);</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Inferred return type is never</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> fail() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> error(</span><span style=\"color: #A31515\">\"Something failed\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Function returning never must have unreachable end point</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> infiniteLoop(): never {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">while</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">) {}</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Some examples of use of functions returning <code>never</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Inferred return type is number</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> move1(direction: </span><span style=\"color: #A31515\">\"up\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"down\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">switch</span><span style=\"color: #000000\"> (direction) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">case</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"up\"</span><span style=\"color: #000000\">:</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">case</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"down\"</span><span style=\"color: #000000\">:</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> -</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> error(</span><span style=\"color: #A31515\">\"Should never get here\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Inferred return type is number</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> move2(direction: </span><span style=\"color: #A31515\">\"up\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"down\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> direction === </span><span style=\"color: #A31515\">\"up\"</span>\n<span style=\"color: #000000\">    ? </span><span style=\"color: #09835A\">1</span>\n<span style=\"color: #000000\">    : direction === </span><span style=\"color: #A31515\">\"down\"</span>\n<span style=\"color: #000000\">    ? -</span><span style=\"color: #09835A\">1</span>\n<span style=\"color: #000000\">    : error(</span><span style=\"color: #A31515\">\"Should never get here\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Inferred return type is T</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> check&lt;T&gt;(x: T | undefined) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x || error(</span><span style=\"color: #A31515\">\"Undefined value\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Because <code>never</code> is assignable to every type, a function returning <code>never</code> can be used when a callback returning a more specific type is required:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> test(cb: () </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> string) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> s = cb();</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> s;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #000000\">test(() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">test(() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> fail());</span>\n<span style=\"color: #000000\">test(() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">throw</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Error();</span>\n<span style=\"color: #000000\">});</span></code></div></pre>\n<h2 id=\"read-only-properties-and-index-signatures\" style=\"position:relative;\"><a href=\"#read-only-properties-and-index-signatures\" aria-label=\"read only properties and index signatures permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Read-only properties and index signatures</h2>\n<p>A property or index signature can now be declared with the <code>readonly</code> modifier is considered read-only.</p>\n<p>Read-only properties may have initializers and may be assigned to in constructors within the same class declaration, but otherwise assignments to read-only properties are disallowed.</p>\n<p>In addition, entities are <em>implicitly</em> read-only in several situations:</p>\n<ul>\n<li>A property declared with a <code>get</code> accessor and no <code>set</code> accessor is considered read-only.</li>\n<li>In the type of an enum object, enum members are considered read-only properties.</li>\n<li>In the type of a module object, exported <code>const</code> variables are considered read-only properties.</li>\n<li>An entity declared in an <code>import</code> statement is considered read-only.</li>\n<li>An entity accessed through an ES2015 namespace import is considered read-only (e.g. <code>foo.x</code> is read-only when <code>foo</code> is declared as <code>import * as foo from \"foo\"</code>).</li>\n</ul>\n<h4 id=\"example-56\" style=\"position:relative;\"><a href=\"#example-56\" aria-label=\"example 56 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Point {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">readonly</span><span style=\"color: #000000\"> x: number;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">readonly</span><span style=\"color: #000000\"> y: number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> p1: Point = { x: </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">, y: </span><span style=\"color: #09835A\">20</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #000000\">p1.x = </span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error, p1.x is read-only</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> p2 = { x: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, y: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> p3: Point = p2; </span><span style=\"color: #008000\">// Ok, read-only alias for p2</span>\n<span style=\"color: #000000\">p3.x = </span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error, p3.x is read-only</span>\n<span style=\"color: #000000\">p2.x = </span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Ok, but also changes p3.x because of aliasing</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Foo {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">readonly</span><span style=\"color: #000000\"> a = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">readonly</span><span style=\"color: #000000\"> b: string;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.b = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Assignment permitted in constructor</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> a: Array&lt;number&gt; = [</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">4</span><span style=\"color: #000000\">];</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> b: ReadonlyArray&lt;number&gt; = a;</span>\n<span style=\"color: #000000\">b[</span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">] = </span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error, elements are read-only</span>\n<span style=\"color: #000000\">b.push(</span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// Error, no push method (because it mutates array)</span>\n<span style=\"color: #000000\">b.length = </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error, length is read-only</span>\n<span style=\"color: #000000\">a = b; </span><span style=\"color: #008000\">// Error, mutating methods are missing</span></code></div></pre>\n<h2 id=\"specifying-the-type-of-this-for-functions\" style=\"position:relative;\"><a href=\"#specifying-the-type-of-this-for-functions\" aria-label=\"specifying the type of this for functions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Specifying the type of <code>this</code> for functions</h2>\n<p>Following up on specifying the type of <code>this</code> in a class or an interface, functions and methods can now declare the type of <code>this</code> they expect.</p>\n<p>By default the type of <code>this</code> inside a function is <code>any</code>.\nStarting with TypeScript 2.0, you can provide an explicit <code>this</code> parameter.\n<code>this</code> parameters are fake parameters that come first in the parameter list of a function:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f(this: void) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// make sure `this` is unusable in this standalone function</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h3 id=\"this-parameters-in-callbacks\" style=\"position:relative;\"><a href=\"#this-parameters-in-callbacks\" aria-label=\"this parameters in callbacks permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>this</code> parameters in callbacks</h3>\n<p>Libraries can also use <code>this</code> parameters to declare how callbacks will be invoked.</p>\n<h4 id=\"example-57\" style=\"position:relative;\"><a href=\"#example-57\" aria-label=\"example 57 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> UIElement {</span>\n<span style=\"color: #000000\">  addClickListener(onclick: (this: void, e: Event) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void): void;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p><code>this: void</code> means that <code>addClickListener</code> expects <code>onclick</code> to be a function that does not require a <code>this</code> type.</p>\n<p>Now if you annotate calling code with <code>this</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Handler {</span>\n<span style=\"color: #000000\">  info: string;</span>\n<span style=\"color: #000000\">  onClickBad(this: Handler, e: Event) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// oops, used this here. using this callback would crash at runtime</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.info = e.message;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> h = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Handler();</span>\n<span style=\"color: #000000\">uiElement.addClickListener(h.onClickBad); </span><span style=\"color: #008000\">// error!</span></code></div></pre>\n<h3 id=\"--noimplicitthis\" style=\"position:relative;\"><a href=\"#--noimplicitthis\" aria-label=\"  noimplicitthis permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>--noImplicitThis</code></h3>\n<p>A new flag is also added in TypeScript 2.0 to flag all uses of <code>this</code> in functions without an explicit type annotation.</p>\n<h2 id=\"glob-support-in-tsconfigjson\" style=\"position:relative;\"><a href=\"#glob-support-in-tsconfigjson\" aria-label=\"glob support in tsconfigjson permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Glob support in <code>tsconfig.json</code></h2>\n<p>Glob support is here!! Glob support has been <a href=\"https://github.com/Microsoft/TypeScript/issues/1927\">one of the most requested features</a>.</p>\n<p>Glob-like file patterns are supported two properties <code>\"include\"</code> and <code>\"exclude\"</code>.</p>\n<h4 id=\"example-58\" style=\"position:relative;\"><a href=\"#example-58\" aria-label=\"example 58 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"compilerOptions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"module\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"commonjs\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"noImplicitAny\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"removeComments\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"preserveConstEnums\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"outFile\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"../../built/local/tsc.js\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"sourceMap\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span>\n<span style=\"color: #000000\">  },</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"include\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"src/**/*\"</span><span style=\"color: #000000\">],</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"exclude\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"node_modules\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"**/*.spec.ts\"</span><span style=\"color: #000000\">]</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>The supported glob wildcards are:</p>\n<ul>\n<li><code>*</code> matches zero or more characters (excluding directory separators)</li>\n<li><code>?</code> matches any one character (excluding directory separators)</li>\n<li><code>**/</code> recursively matches any subdirectory</li>\n</ul>\n<p>If a segment of a glob pattern includes only <code>*</code> or <code>.*</code>, then only files with supported extensions are included (e.g. <code>.ts</code>, <code>.tsx</code>, and <code>.d.ts</code> by default with <code>.js</code> and <code>.jsx</code> if <code>allowJs</code> is set to true).</p>\n<p>If the <code>\"files\"</code> and <code>\"include\"</code> are both left unspecified, the compiler defaults to including all TypeScript (<code>.ts</code>, <code>.d.ts</code> and <code>.tsx</code>) files in the containing directory and subdirectories except those excluded using the <code>\"exclude\"</code> property. JS files (<code>.js</code> and <code>.jsx</code>) are also included if <code>allowJs</code> is set to true.</p>\n<p>If the <code>\"files\"</code> or <code>\"include\"</code> properties are specified, the compiler will instead include the union of the files included by those two properties.\nFiles in the directory specified using the <code>\"outDir\"</code> compiler option are always excluded unless explicitly included via the <code>\"files\"</code> property (even when the ”<code>exclude</code>” property is specified).</p>\n<p>Files included using <code>\"include\"</code> can be filtered using the <code>\"exclude\"</code> property.\nHowever, files included explicitly using the <code>\"files\"</code> property are always included regardless of <code>\"exclude\"</code>.\nThe <code>\"exclude\"</code> property defaults to excluding the <code>node_modules</code>, <code>bower_components</code>, and <code>jspm_packages</code> directories when not specified.</p>\n<h2 id=\"module-resolution-enhancements-baseurl-path-mapping-rootdirs-and-tracing\" style=\"position:relative;\"><a href=\"#module-resolution-enhancements-baseurl-path-mapping-rootdirs-and-tracing\" aria-label=\"module resolution enhancements baseurl path mapping rootdirs and tracing permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Module resolution enhancements: BaseUrl, Path mapping, rootDirs and tracing</h2>\n<p>TypeScript 2.0 provides a set of additional module resolution knops to <em>inform</em> the compiler where to find declarations for a given module.</p>\n<p>See <a href=\"http://www.typescriptlang.org/docs/handbook/module-resolution.html\">Module Resolution</a> documentation for more details.</p>\n<h3 id=\"base-url\" style=\"position:relative;\"><a href=\"#base-url\" aria-label=\"base url permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Base URL</h3>\n<p>Using a <code>baseUrl</code> is a common practice in applications using AMD module loaders where modules are “deployed” to a single folder at run-time.\nAll module imports with non-relative names are assumed to be relative to the <code>baseUrl</code>.</p>\n<h4 id=\"example-59\" style=\"position:relative;\"><a href=\"#example-59\" aria-label=\"example 59 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"compilerOptions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"baseUrl\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./modules\"</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Now imports to <code>\"moduleA\"</code> would be looked up in <code>./modules/moduleA</code></p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> A </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"moduleA\"</span><span style=\"color: #000000\">;</span></code></div></pre>\n<h3 id=\"path-mapping\" style=\"position:relative;\"><a href=\"#path-mapping\" aria-label=\"path mapping permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Path mapping</h3>\n<p>Sometimes modules are not directly located under <em>baseUrl</em>.\nLoaders use a mapping configuration to map module names to files at run-time, see <a href=\"http://requirejs.org/docs/api.html#config-paths\">RequireJs documentation</a> and <a href=\"https://github.com/systemjs/systemjs/blob/master/docs/overview.md#map-config\">SystemJS documentation</a>.</p>\n<p>The TypeScript compiler supports the declaration of such mappings using <code>\"paths\"</code> property in <code>tsconfig.json</code> files.</p>\n<h4 id=\"example-60\" style=\"position:relative;\"><a href=\"#example-60\" aria-label=\"example 60 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<p>For instance, an import to a module <code>\"jquery\"</code> would be translated at runtime to <code>\"node_modules/jquery/dist/jquery.slim.min.js\"</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"compilerOptions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"baseUrl\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./node_modules\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"paths\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0451A5\">\"jquery\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"jquery/dist/jquery.slim.min\"</span><span style=\"color: #000000\">]</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Using <code>\"paths\"</code> also allow for more sophisticated mappings including multiple fall back locations.\nConsider a project configuration where only some modules are available in one location, and the rest are in another.</p>\n<h3 id=\"virtual-directories-with-rootdirs\" style=\"position:relative;\"><a href=\"#virtual-directories-with-rootdirs\" aria-label=\"virtual directories with rootdirs permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Virtual Directories with <code>rootDirs</code></h3>\n<p>Using ‘rootDirs’, you can inform the compiler of the <em>roots</em> making up this “virtual” directory;\nand thus the compiler can resolve relative modules imports within these “virtual” directories <em>as if</em> were merged together in one directory.</p>\n<h4 id=\"example-61\" style=\"position:relative;\"><a href=\"#example-61\" aria-label=\"example 61 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<p>Given this project structure:</p>\n<pre><code class=\"language-tree\"> src\n └── views\n     └── view1.ts (imports './template1')\n     └── view2.ts\n\n generated\n └── templates\n         └── views\n             └── template1.ts (imports './view2')\n</code></pre>\n<p>A build step will copy the files in <code>/src/views</code> and <code>/generated/templates/views</code> to the same directory in the output.\nAt run-time, a view can expect its template to exist next to it, and thus should import it using a relative name as <code>\"./template\"</code>.</p>\n<p><code>\"rootDirs\"</code> specify a list of <em>roots</em> whose contents are expected to merge at run-time.\nSo following our example, the <code>tsconfig.json</code> file should look like:</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"compilerOptions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"rootDirs\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"src/views\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"generated/templates/views\"</span><span style=\"color: #000000\">]</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h3 id=\"tracing-module-resolution\" style=\"position:relative;\"><a href=\"#tracing-module-resolution\" aria-label=\"tracing module resolution permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Tracing module resolution</h3>\n<p><code>--traceResolution</code> offers a handy way to understand how modules have been resolved by the compiler.</p>\n<pre class=\"shiki\"><div class=\"language-id\">shell</div><div class='code-container'><code><span style=\"color: #000000\">tsc --traceResolution</span></code></div></pre>\n<h2 id=\"shorthand-ambient-module-declarations\" style=\"position:relative;\"><a href=\"#shorthand-ambient-module-declarations\" aria-label=\"shorthand ambient module declarations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Shorthand ambient module declarations</h2>\n<p>If you don’t want to take the time to write out declarations before using a new module, you can now just use a shorthand declaration to get started quickly.</p>\n<h4 id=\"declarationsdts\" style=\"position:relative;\"><a href=\"#declarationsdts\" aria-label=\"declarationsdts permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>declarations.d.ts</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">module</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"hot-new-module\"</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>All imports from a shorthand module will have the any type.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> x, { y } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"hot-new-module\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">x(y);</span></code></div></pre>\n<h2 id=\"wildcard-character-in-module-names\" style=\"position:relative;\"><a href=\"#wildcard-character-in-module-names\" aria-label=\"wildcard character in module names permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Wildcard character in module names</h2>\n<p>Importing none-code resources using module loaders extension (e.g. <a href=\"https://github.com/amdjs/amdjs-api/blob/master/LoaderPlugins.md\">AMD</a> or <a href=\"https://github.com/systemjs/systemjs/blob/master/docs/creating-plugins.md\">SystemJS</a>) has not been easy before;\npreviously an ambient module declaration had to be defined for each resource.</p>\n<p>TypeScript 2.0 supports the use of the wildcard character (<code>*</code>) to declare a “family” of module names;\nthis way, a declaration is only required once for an extension, and not for every resource.</p>\n<h4 id=\"example-62\" style=\"position:relative;\"><a href=\"#example-62\" aria-label=\"example 62 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">module</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"*!text\"</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> content: string;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">default</span><span style=\"color: #000000\"> content;</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #008000\">// Some do it the other way around.</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">module</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"json!*\"</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> value: any;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">default</span><span style=\"color: #000000\"> value;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Now you can import things that match <code>\"*!text\"</code> or <code>\"json!*\"</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> fileContent </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./xyz.txt!text\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> data </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"json!http://example.com/data.json\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">console.log(data, fileContent);</span></code></div></pre>\n<p>Wildcard module names can be even more useful when migrating from an un-typed code base.\nCombined with Shorthand ambient module declarations, a set of modules can be easily declared as <code>any</code>.</p>\n<h4 id=\"example-63\" style=\"position:relative;\"><a href=\"#example-63\" aria-label=\"example 63 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">module</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"myLibrary/*\"</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>All imports to any module under <code>myLibrary</code> would be considered to have the type <code>any</code> by the compiler;\nthus, shutting down any checking on the shapes or types of these modules.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> { readFile } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"myLibrary/fileSystem/readFile\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #000000\">readFile(); </span><span style=\"color: #008000\">// readFile is 'any'</span></code></div></pre>\n<h2 id=\"support-for-umd-module-definitions\" style=\"position:relative;\"><a href=\"#support-for-umd-module-definitions\" aria-label=\"support for umd module definitions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for UMD module definitions</h2>\n<p>Some libraries are designed to be used in many module loaders, or with no module loading (global variables).\nThese are known as <a href=\"https://github.com/umdjs/umd\">UMD</a> or <a href=\"http://isomorphic.net\">Isomorphic</a> modules.\nThese libraries can be accessed through either an import or a global variable.</p>\n<p>For example:</p>\n<h5 id=\"math-libdts\" style=\"position:relative;\"><a href=\"#math-libdts\" aria-label=\"math libdts permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>math-lib.d.ts</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> isPrime(x: number): boolean;</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">namespace</span><span style=\"color: #000000\"> mathLib;</span></code></div></pre>\n<p>The library can then be used as an import within modules:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> { isPrime } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"math-lib\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">isPrime(</span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">mathLib.isPrime(</span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// ERROR: can't use the global definition from inside a module</span></code></div></pre>\n<p>It can also be used as a global variable, but only inside of a script.\n(A script is a file with no imports or exports.)</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #000000\">mathLib.isPrime(</span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">);</span></code></div></pre>\n<h2 id=\"optional-class-properties\" style=\"position:relative;\"><a href=\"#optional-class-properties\" aria-label=\"optional class properties permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Optional class properties</h2>\n<p>Optional properties and methods can now be declared in classes, similar to what is already permitted in interfaces.</p>\n<h4 id=\"example-64\" style=\"position:relative;\"><a href=\"#example-64\" aria-label=\"example 64 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Bar {</span>\n<span style=\"color: #000000\">  a: number;</span>\n<span style=\"color: #000000\">  b?: number;</span>\n<span style=\"color: #000000\">  f() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  g?(): number; </span><span style=\"color: #008000\">// Body of optional method can be omitted</span>\n<span style=\"color: #000000\">  h?() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>When compiled in <code>--strictNullChecks</code> mode, optional properties and methods automatically have <code>undefined</code> included in their type. Thus, the <code>b</code> property above is of type <code>number | undefined</code> and the <code>g</code> method above is of type <code>(() => number) | undefined</code>.\nType guards can be used to strip away the <code>undefined</code> part of the type:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> test(x: Bar) {</span>\n<span style=\"color: #000000\">  x.a; </span><span style=\"color: #008000\">// number</span>\n<span style=\"color: #000000\">  x.b; </span><span style=\"color: #008000\">// number | undefined</span>\n<span style=\"color: #000000\">  x.f; </span><span style=\"color: #008000\">// () =&gt; number</span>\n<span style=\"color: #000000\">  x.g; </span><span style=\"color: #008000\">// (() =&gt; number) | undefined</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> f1 = x.f(); </span><span style=\"color: #008000\">// number</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> g1 = x.g && x.g(); </span><span style=\"color: #008000\">// number | undefined</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> g2 = x.g ? x.g() : </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// number</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"private-and-protected-constructors\" style=\"position:relative;\"><a href=\"#private-and-protected-constructors\" aria-label=\"private and protected constructors permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Private and Protected Constructors</h2>\n<p>A class constructor may be marked <code>private</code> or <code>protected</code>.\nA class with private constructor cannot be instantiated outside the class body, and cannot be extended.\nA class with protected constructor cannot be instantiated outside the class body, but can be extended.</p>\n<h4 id=\"example-65\" style=\"position:relative;\"><a href=\"#example-65\" aria-label=\"example 65 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Singleton {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">private</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">static</span><span style=\"color: #000000\"> instance: Singleton;</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">private</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">() {}</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">static</span><span style=\"color: #000000\"> getInstance() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (!Singleton.instance) {</span>\n<span style=\"color: #000000\">      Singleton.instance = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Singleton();</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> Singleton.instance;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> e = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Singleton(); </span><span style=\"color: #008000\">// Error: constructor of 'Singleton' is private.</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v = Singleton.getInstance();</span></code></div></pre>\n<h2 id=\"abstract-properties-and-accessors\" style=\"position:relative;\"><a href=\"#abstract-properties-and-accessors\" aria-label=\"abstract properties and accessors permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Abstract properties and accessors</h2>\n<p>An abstract class can declare abstract properties and/or accessors.\nAny sub class will need to declare the abstract properties or be marked as abstract.\nAbstract properties cannot have an initializer.\nAbstract accessors cannot have bodies.</p>\n<h4 id=\"example-66\" style=\"position:relative;\"><a href=\"#example-66\" aria-label=\"example 66 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">abstract</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Base {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">abstract</span><span style=\"color: #000000\"> name: string;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">abstract</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">get</span><span style=\"color: #000000\"> value();</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">abstract</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">set</span><span style=\"color: #000000\"> value(v: number);</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Derived </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Base {</span>\n<span style=\"color: #000000\">  name = </span><span style=\"color: #A31515\">\"derived\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #000000\">  value = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"implicit-index-signatures\" style=\"position:relative;\"><a href=\"#implicit-index-signatures\" aria-label=\"implicit index signatures permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Implicit index signatures</h2>\n<p>An object literal type is now assignable to a type with an index signature if all known properties in the object literal are assignable to that index signature. This makes it possible to pass a variable that was initialized with an object literal as parameter to a function that expects a map or dictionary:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> httpService(path: string, headers: { [x: string]: string }) {}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> headers = {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #A31515\">\"Content-Type\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"application/x-www-form-urlencoded\"</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #000000\">httpService(</span><span style=\"color: #A31515\">\"\"</span><span style=\"color: #000000\">, { </span><span style=\"color: #A31515\">\"Content-Type\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"application/x-www-form-urlencoded\"</span><span style=\"color: #000000\"> }); </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">httpService(</span><span style=\"color: #A31515\">\"\"</span><span style=\"color: #000000\">, headers); </span><span style=\"color: #008000\">// Now ok, previously wasn't</span></code></div></pre>\n<h2 id=\"including-built-in-type-declarations-with---lib\" style=\"position:relative;\"><a href=\"#including-built-in-type-declarations-with---lib\" aria-label=\"including built in type declarations with   lib permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Including built-in type declarations with <code>--lib</code></h2>\n<p>Getting to ES6/ES2015 built-in API declarations were only limited to <code>target: ES6</code>.\nEnter <code>--lib</code>; with <code>--lib</code> you can specify a list of built-in API declaration groups that you can chose to include in your project.\nFor instance, if you expect your runtime to have support for <code>Map</code>, <code>Set</code> and <code>Promise</code> (e.g. most evergreen browsers today), just include <code>--lib es2015.collection,es2015.promise</code>.\nSimilarly you can exclude declarations you do not want to include in your project, e.g. DOM if you are working on a node project using <code>--lib es5,es6</code>.</p>\n<p>Here is a list of available API groups:</p>\n<ul>\n<li>dom</li>\n<li>webworker</li>\n<li>es5</li>\n<li>es6 / es2015</li>\n<li>es2015.core</li>\n<li>es2015.collection</li>\n<li>es2015.iterable</li>\n<li>es2015.promise</li>\n<li>es2015.proxy</li>\n<li>es2015.reflect</li>\n<li>es2015.generator</li>\n<li>es2015.symbol</li>\n<li>es2015.symbol.wellknown</li>\n<li>es2016</li>\n<li>es2016.array.include</li>\n<li>es2017</li>\n<li>es2017.object</li>\n<li>es2017.sharedmemory</li>\n<li>scripthost</li>\n</ul>\n<h4 id=\"example-67\" style=\"position:relative;\"><a href=\"#example-67\" aria-label=\"example 67 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">bash</div><div class='code-container'><code><span style=\"color: #000000\">tsc --target es5 --lib es5,es2015.promise</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #A31515\">\"compilerOptions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"lib\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"es5\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"es2015.promise\"</span><span style=\"color: #000000\">]</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"flag-unused-declarations-with---nounusedparameters-and---nounusedlocals\" style=\"position:relative;\"><a href=\"#flag-unused-declarations-with---nounusedparameters-and---nounusedlocals\" aria-label=\"flag unused declarations with   nounusedparameters and   nounusedlocals permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Flag unused declarations with <code>--noUnusedParameters</code> and <code>--noUnusedLocals</code></h2>\n<p>TypeScript 2.0 has two new flags to help you maintain a clean code base.\n<code>--noUnusedParameters</code> flags any unused function or method parameters errors.\n<code>--noUnusedLocals</code> flags any unused local (un-exported) declaration like variables, functions, classes, imports, etc…\nAlso, unused private members of a class would be flagged as errors under <code>--noUnusedLocals</code>.</p>\n<h4 id=\"example-68\" style=\"position:relative;\"><a href=\"#example-68\" aria-label=\"example 68 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> B, { readFile } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./b\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #008000\">//     ^ Error: `B` declared but never used</span>\n<span style=\"color: #000000\">readFile();</span>\n\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> write(message: string, args: string[]) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//                                 ^^^^  Error: 'arg' declared but never used.</span>\n<span style=\"color: #000000\">  console.log(message);</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Parameters declaration with names starting with <code>_</code> are exempt from the unused parameter checking.\ne.g.:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> returnNull(_a) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"module-identifiers-allow-for-js-extension\" style=\"position:relative;\"><a href=\"#module-identifiers-allow-for-js-extension\" aria-label=\"module identifiers allow for js extension permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Module identifiers allow for <code>.js</code> extension</h2>\n<p>Before TypeScript 2.0, a module identifier was always assumed to be extension-less;\nfor instance, given an import as <code>import d from \"./moduleA.js\"</code>, the compiler looked up the definition of <code>\"moduleA.js\"</code> in <code>./moduleA.js.ts</code> or <code>./moduleA.js.d.ts</code>.\nThis made it hard to use bundling/loading tools like <a href=\"https://github.com/systemjs/systemjs\">SystemJS</a> that expect URI’s in their module identifier.</p>\n<p>With TypeScript 2.0, the compiler will look up definition of <code>\"moduleA.js\"</code> in <code>./moduleA.ts</code> or <code>./moduleA.d.ts</code>.</p>\n<h2 id=\"support-target--es5-with-module-es6\" style=\"position:relative;\"><a href=\"#support-target--es5-with-module-es6\" aria-label=\"support target  es5 with module es6 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support ‘target : es5’ with ‘module: es6’</h2>\n<p>Previously flagged as an invalid flag combination, <code>target: es5</code> and ‘module: es6’ is now supported.\nThis should facilitate using ES2015-based tree shakers like <a href=\"https://github.com/rollup/rollup\">rollup</a>.</p>\n<h2 id=\"trailing-commas-in-function-parameter-and-argument-lists\" style=\"position:relative;\"><a href=\"#trailing-commas-in-function-parameter-and-argument-lists\" aria-label=\"trailing commas in function parameter and argument lists permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Trailing commas in function parameter and argument lists</h2>\n<p>Trailing comma in function parameter and argument lists are now allowed.\nThis is an implementation for a <a href=\"https://jeffmo.github.io/es-trailing-function-commas/\">Stage-3 ECMAScript proposal</a> that emits down to valid ES3/ES5/ES6.</p>\n<h4 id=\"example-69\" style=\"position:relative;\"><a href=\"#example-69\" aria-label=\"example 69 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> foo(</span>\n<span style=\"color: #000000\">  bar: Bar,</span>\n<span style=\"color: #000000\">  baz: Baz </span><span style=\"color: #008000\">// trailing commas are OK in parameter lists</span>\n<span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Implementation...</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #000000\">foo(</span>\n<span style=\"color: #000000\">  bar,</span>\n<span style=\"color: #000000\">  baz </span><span style=\"color: #008000\">// and in argument lists</span>\n<span style=\"color: #000000\">);</span></code></div></pre>\n<h2 id=\"new---skiplibcheck\" style=\"position:relative;\"><a href=\"#new---skiplibcheck\" aria-label=\"new   skiplibcheck permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New <code>--skipLibCheck</code></h2>\n<p>TypeScript 2.0 adds a new <code>--skipLibCheck</code> compiler option that causes type checking of declaration files (files with extension <code>.d.ts</code>) to be skipped.\nWhen a program includes large declaration files, the compiler spends a lot of time type checking declarations that are already known to not contain errors, and compile times may be significantly shortened by skipping declaration file type checks.</p>\n<p>Since declarations in one file can affect type checking in other files, some errors may not be detected when <code>--skipLibCheck</code> is specified.\nFor example, if a non-declaration file augments a type declared in a declaration file, errors may result that are only reported when the declaration file is checked.\nHowever, in practice such situations are rare.</p>\n<h2 id=\"allow-duplicate-identifiers-across-declarations\" style=\"position:relative;\"><a href=\"#allow-duplicate-identifiers-across-declarations\" aria-label=\"allow duplicate identifiers across declarations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Allow duplicate identifiers across declarations</h2>\n<p>This has been one common source of duplicate definition errors.\nMultiple declaration files defining the same members on interfaces.</p>\n<p>TypeScript 2.0 relaxes this constraint and allows duplicate identifiers across blocks, as long as they have <em>identical</em> types.</p>\n<p>Within the same block duplicate definitions are still disallowed.</p>\n<h4 id=\"example-70\" style=\"position:relative;\"><a href=\"#example-70\" aria-label=\"example 70 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Error {</span>\n<span style=\"color: #000000\">  stack?: string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Error {</span>\n<span style=\"color: #000000\">  code?: string;</span>\n<span style=\"color: #000000\">  path?: string;</span>\n<span style=\"color: #000000\">  stack?: string; </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"new---declarationdir\" style=\"position:relative;\"><a href=\"#new---declarationdir\" aria-label=\"new   declarationdir permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New <code>--declarationDir</code></h2>\n<p><code>--declarationDir</code> allows for generating declaration files in a different location than JavaScript files.</p>\n<h2 id=\"typescript-18\" style=\"position:relative;\"><a href=\"#typescript-18\" aria-label=\"typescript 18 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 1.8</h2>\n<h2 id=\"type-parameters-as-constraints\" style=\"position:relative;\"><a href=\"#type-parameters-as-constraints\" aria-label=\"type parameters as constraints permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Type parameters as constraints</h2>\n<p>With TypeScript 1.8 it becomes possible for a type parameter constraint to reference type parameters from the same type parameter list. Previously this was an error. This capability is usually referred to as <a href=\"https://en.wikipedia.org/wiki/Bounded_quantification#F-bounded_quantification\">F-Bounded Polymorphism</a>.</p>\n<h5 id=\"example-71\" style=\"position:relative;\"><a href=\"#example-71\" aria-label=\"example 71 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> assign&lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> U, U&gt;(target: T, source: U): T {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> id </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> source) {</span>\n<span style=\"color: #000000\">    target[id] = source[id];</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> target;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = { a: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, b: </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">, c: </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">, d: </span><span style=\"color: #09835A\">4</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #000000\">assign(x, { b: </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">, d: </span><span style=\"color: #09835A\">20</span><span style=\"color: #000000\"> });</span>\n<span style=\"color: #000000\">assign(x, { e: </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\"> }); </span><span style=\"color: #008000\">// Error</span></code></div></pre>\n<h2 id=\"control-flow-analysis-errors\" style=\"position:relative;\"><a href=\"#control-flow-analysis-errors\" aria-label=\"control flow analysis errors permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Control flow analysis errors</h2>\n<p>TypeScript 1.8 introduces control flow analysis to help catch common errors that users tend to run into.\nRead on to get more details, and check out these errors in action:</p>\n<p><img src=\"https://cloud.githubusercontent.com/assets/8052307/5210657/c5ae0f28-7585-11e4-97d8-86169ef2a160.gif\" alt=\"cfa\"></p>\n<h3 id=\"unreachable-code\" style=\"position:relative;\"><a href=\"#unreachable-code\" aria-label=\"unreachable code permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Unreachable code</h3>\n<p>Statements guaranteed to not be executed at run time are now correctly flagged as unreachable code errors. For instance, statements following unconditional <code>return</code>, <code>throw</code>, <code>break</code> or <code>continue</code> statements are considered unreachable. Use <code>--allowUnreachableCode</code> to disable unreachable code detection and reporting.</p>\n<h5 id=\"example-72\" style=\"position:relative;\"><a href=\"#example-72\" aria-label=\"example 72 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<p>Here’s a simple example of an unreachable code error:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f(x) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (x) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  } </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n\n<span style=\"color: #000000\">  x = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error: Unreachable code detected.</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>A more common error that this feature catches is adding a newline after a <code>return</code> statement:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Automatic Semicolon Insertion triggered at newline</span>\n<span style=\"color: #000000\">  {</span>\n<span style=\"color: #000000\">    x: </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error: Unreachable code detected.</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Since JavaScript automatically terminates the <code>return</code> statement at the end of the line, the object literal becomes a block.</p>\n<h3 id=\"unused-labels\" style=\"position:relative;\"><a href=\"#unused-labels\" aria-label=\"unused labels permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Unused labels</h3>\n<p>Unused labels are also flagged. Just like unreachable code checks, these are turned on by default; use <code>--allowUnusedLabels</code> to stop reporting these errors.</p>\n<h5 id=\"example-73\" style=\"position:relative;\"><a href=\"#example-73\" aria-label=\"example 73 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #000000\">loop: </span><span style=\"color: #0000FF\">while</span><span style=\"color: #000000\"> (x &gt; </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Error: Unused label.</span>\n<span style=\"color: #000000\">  x++;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h3 id=\"implicit-returns\" style=\"position:relative;\"><a href=\"#implicit-returns\" aria-label=\"implicit returns permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Implicit returns</h3>\n<p>Functions with code paths that do not return a value in JS implicitly return <code>undefined</code>. These can now be flagged by the compiler as implicit returns. The check is turned <em>off</em> by default; use <code>--noImplicitReturns</code> to turn it on.</p>\n<h5 id=\"example-74\" style=\"position:relative;\"><a href=\"#example-74\" aria-label=\"example 74 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f(x) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Error: Not all code paths return a value.</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (x) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// implicitly returns `undefined`</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h3 id=\"case-clause-fall-throughs\" style=\"position:relative;\"><a href=\"#case-clause-fall-throughs\" aria-label=\"case clause fall throughs permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Case clause fall-throughs</h3>\n<p>TypeScript can reports errors for fall-through cases in switch statement where the case clause is non-empty.\nThis check is turned <em>off</em> by default, and can be enabled using <code>--noFallthroughCasesInSwitch</code>.</p>\n<h5 id=\"example-75\" style=\"position:relative;\"><a href=\"#example-75\" aria-label=\"example 75 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<p>With <code>--noFallthroughCasesInSwitch</code>, this example will trigger an error:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">switch</span><span style=\"color: #000000\"> (x % </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">case</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">: </span><span style=\"color: #008000\">// Error: Fallthrough case in switch.</span>\n<span style=\"color: #000000\">    console.log(</span><span style=\"color: #A31515\">\"even\"</span><span style=\"color: #000000\">);</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">case</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">:</span>\n<span style=\"color: #000000\">    console.log(</span><span style=\"color: #A31515\">\"odd\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">break</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>However, in the following example, no error will be reported because the fall-through case is empty:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">switch</span><span style=\"color: #000000\"> (x % </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">case</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">:</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">case</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">:</span>\n<span style=\"color: #000000\">    console.log(</span><span style=\"color: #A31515\">\"Acceptable\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">break</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">case</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">:</span>\n<span style=\"color: #000000\">    console.log(</span><span style=\"color: #A31515\">\"This is *two much*!\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">break</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"stateless-function-components-in-react\" style=\"position:relative;\"><a href=\"#stateless-function-components-in-react\" aria-label=\"stateless function components in react permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Stateless Function Components in React</h2>\n<p>TypeScript now supports <a href=\"https://facebook.github.io/react/docs/reusable-components.html#stateless-functions\">Stateless Function components</a>.\nThese are lightweight components that easily compose other components:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Use parameter destructuring and defaults for easy definition of 'props' type</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> Greeter = ({ name = </span><span style=\"color: #A31515\">\"world\"</span><span style=\"color: #000000\"> }) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> &lt;div&gt;Hello, {name}!&lt;/div&gt;;</span>\n\n<span style=\"color: #008000\">// Properties get validated</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> example = &lt;Greeter name=</span><span style=\"color: #A31515\">\"TypeScript 1.8\"</span><span style=\"color: #000000\"> /&gt;;</span></code></div></pre>\n<p>For this feature and simplified props, be sure to be use the <a href=\"https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/react\">latest version of react.d.ts</a>.</p>\n<h2 id=\"simplified-props-type-management-in-react\" style=\"position:relative;\"><a href=\"#simplified-props-type-management-in-react\" aria-label=\"simplified props type management in react permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Simplified <code>props</code> type management in React</h2>\n<p>In TypeScript 1.8 with the latest version of react.d.ts (see above), we’ve also greatly simplified the declaration of <code>props</code> types.</p>\n<p>Specifically:</p>\n<ul>\n<li>You no longer need to either explicitly declare <code>ref</code> and <code>key</code> or <code>extend React.Props</code></li>\n<li>The <code>ref</code> and <code>key</code> properties will appear with correct types on all components</li>\n<li>The <code>ref</code> property is correctly disallowed on instances of Stateless Function components</li>\n</ul>\n<h2 id=\"augmenting-globalmodule-scope-from-modules\" style=\"position:relative;\"><a href=\"#augmenting-globalmodule-scope-from-modules\" aria-label=\"augmenting globalmodule scope from modules permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Augmenting global/module scope from modules</h2>\n<p>Users can now declare any augmentations that they want to make, or that any other consumers already have made, to an existing module.\nModule augmentations look like plain old ambient module declarations (i.e. the <code>declare module \"foo\" { }</code> syntax), and are directly nested either your own modules, or in another top level ambient external module.</p>\n<p>Furthermore, TypeScript also has the notion of <em>global</em> augmentations of the form <code>declare global { }</code>.\nThis allows modules to augment global types such as <code>Array</code> if necessary.</p>\n<p>The name of a module augmentation is resolved using the same set of rules as module specifiers in <code>import</code> and <code>export</code> declarations.\nThe declarations in a module augmentation are merged with any existing declarations the same way they would if they were declared in the same file.</p>\n<p>Neither module augmentations nor global augmentations can add new items to the top level scope - they can only “patch” existing declarations.</p>\n<h5 id=\"example-76\" style=\"position:relative;\"><a href=\"#example-76\" aria-label=\"example 76 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<p>Here <code>map.ts</code> can declare that it will internally patch the <code>Observable</code> type from <code>observable.ts</code> and add the <code>map</code> method to it.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// observable.ts</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Observable&lt;T&gt; {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// ...</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// map.ts</span>\n<span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> { Observable } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./observable\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #008000\">// Create an augmentation for \"./observable\"</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">module</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./observable\"</span><span style=\"color: #000000\"> {</span>\n\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// Augment the 'Observable' class definition with interface merging</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Observable&lt;T&gt; {</span>\n<span style=\"color: #000000\">        map&lt;U&gt;(proj: (el: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> U): Observable&lt;U&gt;;</span>\n<span style=\"color: #000000\">    }</span>\n\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #000000\">Observable.prototype.map = </span><span style=\"color: #008000\">/*...*/</span><span style=\"color: #000000\">;</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// consumer.ts</span>\n<span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> { Observable } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./observable\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./map\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> o: Observable&lt;number&gt;;</span>\n<span style=\"color: #000000\">o.map(x </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> x.toFixed());</span></code></div></pre>\n<p>Similarly, the global scope can be augmented from modules using a <code>declare global</code> declarations:</p>\n<h5 id=\"example-77\" style=\"position:relative;\"><a href=\"#example-77\" aria-label=\"example 77 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Ensure this is treated as a module.</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> {};</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> global {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Array&lt;T&gt; {</span>\n<span style=\"color: #000000\">    mapToNumbers(): number[];</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #000000\">Array.prototype.mapToNumbers = </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">/* ... */</span>\n<span style=\"color: #000000\">};</span></code></div></pre>\n<h2 id=\"string-literal-types\" style=\"position:relative;\"><a href=\"#string-literal-types\" aria-label=\"string literal types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>String literal types</h2>\n<p>It’s not uncommon for an API to expect a specific set of strings for certain values.\nFor instance, consider a UI library that can move elements across the screen while controlling the <a href=\"https://en.wikipedia.org/wiki/Inbetweening\">“easing” of the animation.</a></p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> UIElement {</span>\n<span style=\"color: #000000\">  animate(options: AnimationOptions): void;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> AnimationOptions {</span>\n<span style=\"color: #000000\">  deltaX: number;</span>\n<span style=\"color: #000000\">  deltaY: number;</span>\n<span style=\"color: #000000\">  easing: string; </span><span style=\"color: #008000\">// Can be \"ease-in\", \"ease-out\", \"ease-in-out\"</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>However, this is error prone - there is nothing stopping a user from accidentally misspelling one of the valid easing values:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// No errors</span>\n<span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> UIElement().animate({ deltaX: </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">, deltaY: </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">, easing: </span><span style=\"color: #A31515\">\"ease-inout\"</span><span style=\"color: #000000\"> });</span></code></div></pre>\n<p>With TypeScript 1.8, we’ve introduced string literal types.\nThese types are written the same way string literals are, but in type positions.</p>\n<p>Users can now ensure that the type system will catch such errors.\nHere’s our new <code>AnimationOptions</code> using string literal types:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> AnimationOptions {</span>\n<span style=\"color: #000000\">  deltaX: number;</span>\n<span style=\"color: #000000\">  deltaY: number;</span>\n<span style=\"color: #000000\">  easing: </span><span style=\"color: #A31515\">\"ease-in\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"ease-out\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"ease-in-out\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Error: Type '\"ease-inout\"' is not assignable to type '\"ease-in\" | \"ease-out\" | \"ease-in-out\"'</span>\n<span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> UIElement().animate({ deltaX: </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">, deltaY: </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">, easing: </span><span style=\"color: #A31515\">\"ease-inout\"</span><span style=\"color: #000000\"> });</span></code></div></pre>\n<h2 id=\"improved-unionintersection-type-inference\" style=\"position:relative;\"><a href=\"#improved-unionintersection-type-inference\" aria-label=\"improved unionintersection type inference permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Improved union/intersection type inference</h2>\n<p>TypeScript 1.8 improves type inference involving source and target sides that are both union or intersection types.\nFor example, when inferring from <code>string | string[]</code> to <code>string | T</code>, we reduce the types to <code>string[]</code> and <code>T</code>, thus inferring <code>string[]</code> for <code>T</code>.</p>\n<h5 id=\"example-78\" style=\"position:relative;\"><a href=\"#example-78\" aria-label=\"example 78 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Maybe&lt;T&gt; = T | void;</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> isDefined&lt;T&gt;(x: Maybe&lt;T&gt;): x </span><span style=\"color: #0000FF\">is</span><span style=\"color: #000000\"> T {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x !== </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\"> && x !== </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> isUndefined&lt;T&gt;(x: Maybe&lt;T&gt;): x </span><span style=\"color: #0000FF\">is</span><span style=\"color: #000000\"> void {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x === </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\"> || x === </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> getOrElse&lt;T&gt;(x: Maybe&lt;T&gt;, defaultValue: T): T {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> isDefined(x) ? x : defaultValue;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> test1(x: Maybe&lt;string&gt;) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x1 = getOrElse(x, </span><span style=\"color: #A31515\">\"Undefined\"</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x2 = isDefined(x) ? x : </span><span style=\"color: #A31515\">\"Undefined\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x3 = isUndefined(x) ? </span><span style=\"color: #A31515\">\"Undefined\"</span><span style=\"color: #000000\"> : x; </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> test2(x: Maybe&lt;number&gt;) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x1 = getOrElse(x, -</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// number</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x2 = isDefined(x) ? x : -</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// number</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x3 = isUndefined(x) ? -</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> : x; </span><span style=\"color: #008000\">// number</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"concatenate-amd-and-system-modules-with---outfile\" style=\"position:relative;\"><a href=\"#concatenate-amd-and-system-modules-with---outfile\" aria-label=\"concatenate amd and system modules with   outfile permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Concatenate <code>AMD</code> and <code>System</code> modules with <code>--outFile</code></h2>\n<p>Specifying <code>--outFile</code> in conjunction with <code>--module amd</code> or <code>--module system</code> will concatenate all modules in the compilation into a single output file containing multiple module closures.</p>\n<p>A module name will be computed for each module based on its relative location to <code>rootDir</code>.</p>\n<h5 id=\"example-79\" style=\"position:relative;\"><a href=\"#example-79\" aria-label=\"example 79 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// file src/a.ts</span>\n<span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">*</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> B </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./lib/b\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> createA() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> B.createB();</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// file src/lib/b.ts</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> createB() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> {};</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Results in:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #000000\">define(</span><span style=\"color: #A31515\">\"lib/b\"</span><span style=\"color: #000000\">, [</span><span style=\"color: #A31515\">\"require\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"exports\"</span><span style=\"color: #000000\">], </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(require, exports) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #A31515\">\"use strict\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> createB() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> {};</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  exports.createB = createB;</span>\n<span style=\"color: #000000\">});</span>\n<span style=\"color: #000000\">define(</span><span style=\"color: #A31515\">\"a\"</span><span style=\"color: #000000\">, [</span><span style=\"color: #A31515\">\"require\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"exports\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"lib/b\"</span><span style=\"color: #000000\">], </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(require, exports, B) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #A31515\">\"use strict\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> createA() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> B.createB();</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  exports.createA = createA;</span>\n<span style=\"color: #000000\">});</span></code></div></pre>\n<h2 id=\"support-for-default-import-interop-with-systemjs\" style=\"position:relative;\"><a href=\"#support-for-default-import-interop-with-systemjs\" aria-label=\"support for default import interop with systemjs permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for <code>default</code> import interop with SystemJS</h2>\n<p>Module loaders like SystemJS wrap CommonJS modules and expose then as a <code>default</code> ES6 import. This makes it impossible to share the definition files between the SystemJS and CommonJS implementation of the module as the module shape looks different based on the loader.</p>\n<p>Setting the new compiler flag <code>--allowSyntheticDefaultImports</code> indicates that the module loader performs some kind of synthetic default import member creation not indicated in the imported .ts or .d.ts. The compiler will infer the existence of a <code>default</code> export that has the shape of the entire module itself.</p>\n<p>System modules have this flag on by default.</p>\n<h2 id=\"allow-captured-letconst-in-loops\" style=\"position:relative;\"><a href=\"#allow-captured-letconst-in-loops\" aria-label=\"allow captured letconst in loops permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Allow captured <code>let</code>/<code>const</code> in loops</h2>\n<p>Previously an error, now supported in TypeScript 1.8.\n<code>let</code>/<code>const</code> declarations within loops and captured in functions are now emitted to correctly match <code>let</code>/<code>const</code> freshness semantics.</p>\n<h5 id=\"example-80\" style=\"position:relative;\"><a href=\"#example-80\" aria-label=\"example 80 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> list = [];</span>\n<span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> i = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">; i &lt; </span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">; i++) {</span>\n<span style=\"color: #000000\">  list.push(() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> i);</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #000000\">list.forEach(f </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> console.log(f()));</span></code></div></pre>\n<p>is compiled to:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> list = [];</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> _loop_1 = </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(i) {</span>\n<span style=\"color: #000000\">  list.push(</span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> i;</span>\n<span style=\"color: #000000\">  });</span>\n<span style=\"color: #000000\">};</span>\n<span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> i = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">; i &lt; </span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">; i++) {</span>\n<span style=\"color: #000000\">  _loop_1(i);</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #000000\">list.forEach(</span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(f) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> console.log(f());</span>\n<span style=\"color: #000000\">});</span></code></div></pre>\n<p>And results in</p>\n<pre class=\"shiki\"><div class=\"language-id\">cmd</div><div class='code-container'><code><span style=\"color: #09835A\">0</span>\n<span style=\"color: #09835A\">1</span>\n<span style=\"color: #09835A\">2</span>\n<span style=\"color: #09835A\">3</span>\n<span style=\"color: #09835A\">4</span></code></div></pre>\n<h2 id=\"improved-checking-for-forin-statements\" style=\"position:relative;\"><a href=\"#improved-checking-for-forin-statements\" aria-label=\"improved checking for forin statements permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Improved checking for <code>for..in</code> statements</h2>\n<p>Previously the type of a <code>for..in</code> variable is inferred to <code>any</code>; that allowed the compiler to ignore invalid uses within the <code>for..in</code> body.</p>\n<p>Starting with TypeScript 1.8,:</p>\n<ul>\n<li>The type of a variable declared in a <code>for..in</code> statement is implicitly <code>string</code>.</li>\n<li>When an object with a numeric index signature of type <code>T</code> (such as an array) is indexed by a <code>for..in</code> variable of a containing <code>for..in</code> statement for an object <em>with</em> a numeric index signature and <em>without</em> a string index signature (again such as an array), the value produced is of type <code>T</code>.</li>\n</ul>\n<h5 id=\"example-81\" style=\"position:relative;\"><a href=\"#example-81\" aria-label=\"example 81 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> a: MyObject[];</span>\n<span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> a) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Type of x is implicitly string</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> obj = a[x]; </span><span style=\"color: #008000\">// Type of obj is MyObject</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"modules-are-now-emitted-with-a-use-strict-prologue\" style=\"position:relative;\"><a href=\"#modules-are-now-emitted-with-a-use-strict-prologue\" aria-label=\"modules are now emitted with a use strict prologue permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Modules are now emitted with a <code>\"use strict\";</code> prologue</h2>\n<p>Modules were always parsed in strict mode as per ES6, but for non-ES6 targets this was not respected in the generated code. Starting with TypeScript 1.8, emitted modules are always in strict mode. This shouldn’t have any visible changes in most code as TS considers most strict mode errors as errors at compile time, but it means that some things which used to silently fail at runtime in your TS code, like assigning to <code>NaN</code>, will now loudly fail. You can reference the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode\">MDN Article</a> on strict mode for a detailed list of the differences between strict mode and non-strict mode.</p>\n<h2 id=\"including-js-files-with---allowjs\" style=\"position:relative;\"><a href=\"#including-js-files-with---allowjs\" aria-label=\"including js files with   allowjs permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Including <code>.js</code> files with <code>--allowJs</code></h2>\n<p>Often there are external source files in your project that may not be authored in TypeScript.\nAlternatively, you might be in the middle of converting a JS code base into TS, but still want to bundle all your JS code into a single file with the output of your new TS code.</p>\n<p><code>.js</code> files are now allowed as input to <code>tsc</code>.\nThe TypeScript compiler checks the input <code>.js</code> files for syntax errors, and emits valid output based on the <code>--target</code> and <code>--module</code> flags.\nThe output can be combined with other <code>.ts</code> files as well.\nSource maps are still generated for <code>.js</code> files just like with <code>.ts</code> files.</p>\n<h2 id=\"custom-jsx-factories-using---reactnamespace\" style=\"position:relative;\"><a href=\"#custom-jsx-factories-using---reactnamespace\" aria-label=\"custom jsx factories using   reactnamespace permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Custom JSX factories using <code>--reactNamespace</code></h2>\n<p>Passing <code>--reactNamespace &#x3C;JSX factory Name></code> along with <code>--jsx react</code> allows for using a different JSX factory from the default <code>React</code>.</p>\n<p>The new factory name will be used to call <code>createElement</code> and <code>__spread</code> functions.</p>\n<h5 id=\"example-82\" style=\"position:relative;\"><a href=\"#example-82\" aria-label=\"example 82 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> { jsxFactory } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"jsxFactory\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> div = &lt;div&gt;Hello JSX!&lt;/div&gt;;</span></code></div></pre>\n<p>Compiled with:</p>\n<pre class=\"shiki\"><div class=\"language-id\">shell</div><div class='code-container'><code><span style=\"color: #000000\">tsc --jsx react --reactNamespace jsxFactory --m commonJS</span></code></div></pre>\n<p>Results in:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #A31515\">\"use strict\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> jsxFactory_1 = require(</span><span style=\"color: #A31515\">\"jsxFactory\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> div = jsxFactory_1.jsxFactory.createElement(</span><span style=\"color: #A31515\">\"div\"</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"Hello JSX!\"</span><span style=\"color: #000000\">);</span></code></div></pre>\n<h2 id=\"this-based-type-guards\" style=\"position:relative;\"><a href=\"#this-based-type-guards\" aria-label=\"this based type guards permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>this</code>-based type guards</h2>\n<p>TypeScript 1.8 extends <a href=\"#user-defined-type-guard-functions\">user-defined type guard functions</a> to class and interface methods.</p>\n<p><code>this is T</code> is now valid return type annotation for methods in classes and interfaces.\nWhen used in a type narrowing position (e.g. <code>if</code> statement), the type of the call expression target object would be narrowed to <code>T</code>.</p>\n<h5 id=\"example-83\" style=\"position:relative;\"><a href=\"#example-83\" aria-label=\"example 83 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> FileSystemObject {</span>\n<span style=\"color: #000000\">  isFile(): this </span><span style=\"color: #0000FF\">is</span><span style=\"color: #000000\"> File {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">instanceof</span><span style=\"color: #000000\"> File;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  isDirectory(): this </span><span style=\"color: #0000FF\">is</span><span style=\"color: #000000\"> Directory {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">instanceof</span><span style=\"color: #000000\"> Directory;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  isNetworked(): this </span><span style=\"color: #0000FF\">is</span><span style=\"color: #000000\"> Networked & this {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.networked;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(</span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> path: string, </span><span style=\"color: #0000FF\">private</span><span style=\"color: #000000\"> networked: boolean) {}</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> File </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> FileSystemObject {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(path: string, </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> content: string) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">super</span><span style=\"color: #000000\">(path, </span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Directory </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> FileSystemObject {</span>\n<span style=\"color: #000000\">  children: FileSystemObject[];</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Networked {</span>\n<span style=\"color: #000000\">  host: string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> fso: FileSystemObject = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> File(</span><span style=\"color: #A31515\">\"foo/bar.txt\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"foo\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (fso.isFile()) {</span>\n<span style=\"color: #000000\">  fso.content; </span><span style=\"color: #008000\">// fso is File</span>\n<span style=\"color: #000000\">} </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (fso.isDirectory()) {</span>\n<span style=\"color: #000000\">  fso.children; </span><span style=\"color: #008000\">// fso is Directory</span>\n<span style=\"color: #000000\">} </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (fso.isNetworked()) {</span>\n<span style=\"color: #000000\">  fso.host; </span><span style=\"color: #008000\">// fso is networked</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"official-typescript-nuget-package\" style=\"position:relative;\"><a href=\"#official-typescript-nuget-package\" aria-label=\"official typescript nuget package permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Official TypeScript NuGet package</h2>\n<p>Starting with TypeScript 1.8, official NuGet packages are available for the Typescript Compiler (<code>tsc.exe</code>) as well as the MSBuild integration (<code>Microsoft.TypeScript.targets</code> and <code>Microsoft.TypeScript.Tasks.dll</code>).</p>\n<p>Stable packages are available here:</p>\n<ul>\n<li><a href=\"https://www.nuget.org/packages/Microsoft.TypeScript.Compiler/\">Microsoft.TypeScript.Compiler</a></li>\n<li><a href=\"https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild/\">Microsoft.TypeScript.MSBuild</a></li>\n</ul>\n<p>Also, a nightly NuGet package to match the <a href=\"http://blogs.msdn.com/b/typescript/archive/2015/07/27/introducing-typescript-nightlies.aspx\">nightly npm package</a> is available on <a href=\"https://myget.org\">https://myget.org</a>:</p>\n<ul>\n<li><a href=\"https://www.myget.org/gallery/typescript-preview\">TypeScript-Preview</a></li>\n</ul>\n<h2 id=\"prettier-error-messages-from-tsc\" style=\"position:relative;\"><a href=\"#prettier-error-messages-from-tsc\" aria-label=\"prettier error messages from tsc permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Prettier error messages from <code>tsc</code></h2>\n<p>We understand that a ton of monochrome output can be a little difficult on the eyes.\nColors can help discern where a message starts and ends, and these visual clues are important when error output gets overwhelming.</p>\n<p>By just passing the <code>--pretty</code> command line option, TypeScript gives more colorful output with context about where things are going wrong.</p>\n<p><img src=\"https://raw.githubusercontent.com/wiki/Microsoft/TypeScript/images/new-in-typescript/pretty01.png\" alt=\"Showing off pretty error messages in ConEmu\"></p>\n<h2 id=\"colorization-of-jsx-code-in-vs-2015\" style=\"position:relative;\"><a href=\"#colorization-of-jsx-code-in-vs-2015\" aria-label=\"colorization of jsx code in vs 2015 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Colorization of JSX code in VS 2015</h2>\n<p>With TypeScript 1.8, JSX tags are now classified and colorized in Visual Studio 2015.</p>\n<p><img src=\"https://cloud.githubusercontent.com/assets/8052307/12271404/b875c502-b90f-11e5-93d8-c6740be354d1.png\" alt=\"jsx\"></p>\n<p>The classification can be further customized by changing the font and color settings for the <code>VB XML</code> color and font settings through <code>Tools</code>-><code>Options</code>-><code>Environment</code>-><code>Fonts and Colors</code> page.</p>\n<h2 id=\"the---project--p-flag-can-now-take-any-file-path\" style=\"position:relative;\"><a href=\"#the---project--p-flag-can-now-take-any-file-path\" aria-label=\"the   project  p flag can now take any file path permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The <code>--project</code> (<code>-p</code>) flag can now take any file path</h2>\n<p>The <code>--project</code> command line option originally could only take paths to a folder containing a <code>tsconfig.json</code>.\nGiven the different scenarios for build configurations, it made sense to allow <code>--project</code> to point to any other compatible JSON file.\nFor instance, a user might want to target ES2015 with CommonJS modules for Node 5, but ES5 with AMD modules for the browser.\nWith this new work, users can easily manage two separate build targets using <code>tsc</code> alone without having to perform hacky workarounds like placing <code>tsconfig.json</code> files in separate directories.</p>\n<p>The old behavior still remains the same if given a directory - the compiler will try to find a file in the directory named <code>tsconfig.json</code>.</p>\n<h2 id=\"allow-comments-in-tsconfigjson\" style=\"position:relative;\"><a href=\"#allow-comments-in-tsconfigjson\" aria-label=\"allow comments in tsconfigjson permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Allow comments in tsconfig.json</h2>\n<p>It’s always nice to be able to document your configuration!\n<code>tsconfig.json</code> now accepts single and multi-line comments.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #A31515\">\"compilerOptions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #A31515\">\"target\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"ES2015\"</span><span style=\"color: #000000\">, </span><span style=\"color: #008000\">// running on node v5, yaay!</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #A31515\">\"sourceMap\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">   </span><span style=\"color: #008000\">// makes debugging easier</span>\n<span style=\"color: #000000\">    },</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">/*</span>\n<span style=\"color: #008000\">     * Excluded files</span>\n<span style=\"color: #008000\">      */</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #A31515\">\"exclude\"</span><span style=\"color: #000000\">: [</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #A31515\">\"file.d.ts\"</span>\n<span style=\"color: #000000\">    ]</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"support-output-to-ipc-driven-files\" style=\"position:relative;\"><a href=\"#support-output-to-ipc-driven-files\" aria-label=\"support output to ipc driven files permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support output to IPC-driven files</h2>\n<p>TypeScript 1.8 allows users to use the <code>--outFile</code> argument with special file system entities like named pipes, devices, etc.</p>\n<p>As an example, on many Unix-like systems, the standard output stream is accessible by the file <code>/dev/stdout</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">shell</div><div class='code-container'><code><span style=\"color: #000000\">tsc foo.ts --outFile /dev/stdout</span></code></div></pre>\n<p>This can be used to pipe output between commands as well.</p>\n<p>As an example, we can pipe our emitted JavaScript into a pretty printer like <a href=\"https://www.npmjs.com/package/pretty-js\">pretty-js</a>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">shell</div><div class='code-container'><code><span style=\"color: #000000\">tsc foo.ts --outFile /dev/stdout | pretty-js</span></code></div></pre>\n<h2 id=\"improved-support-for-tsconfigjson-in-visual-studio-2015\" style=\"position:relative;\"><a href=\"#improved-support-for-tsconfigjson-in-visual-studio-2015\" aria-label=\"improved support for tsconfigjson in visual studio 2015 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Improved support for <code>tsconfig.json</code> in Visual Studio 2015</h2>\n<p>TypeScript 1.8 allows <code>tsconfig.json</code> files in all project types.\nThis includes ASP.NET v4 projects, <em>Console Application</em>, and the <em>Html Application with TypeScript</em> project types.\nFurther, you are no longer limited to a single <code>tsconfig.json</code> file but can add multiple, and each will be built as part of the project.\nThis allows you to separate the configuration for different parts of your application without having to use multiple different projects.</p>\n<p><img src=\"https://raw.githubusercontent.com/wiki/Microsoft/TypeScript/images/new-in-typescript/tsconfig-in-vs.png\" alt=\"Showing off tsconfig.json in Visual Studio\"></p>\n<p>We also disable the project properties page when you add a <code>tsconfig.json</code> file.\nThis means that all configuration changes have to be made in the <code>tsconfig.json</code> file itself.</p>\n<h3 id=\"a-couple-of-limitations\" style=\"position:relative;\"><a href=\"#a-couple-of-limitations\" aria-label=\"a couple of limitations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>A couple of limitations:</h3>\n<ul>\n<li>If you add a <code>tsconfig.json</code> file, TypeScript files that are not considered part of that context are not compiled.</li>\n<li>Apache Cordova Apps still have the existing limitation of a single <code>tsconfig.json</code> file, which must be in either the root or the <code>scripts</code> folder.</li>\n<li>There is no template for <code>tsconfig.json</code> in most project types.</li>\n</ul>\n<h2 id=\"typescript-17\" style=\"position:relative;\"><a href=\"#typescript-17\" aria-label=\"typescript 17 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 1.7</h2>\n<h2 id=\"asyncawait-support-in-es6-targets-node-v4\" style=\"position:relative;\"><a href=\"#asyncawait-support-in-es6-targets-node-v4\" aria-label=\"asyncawait support in es6 targets node v4 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>async</code>/<code>await</code> support in ES6 targets (Node v4+)</h2>\n<p>TypeScript now supports asynchronous functions for engines that have native support for ES6 generators, e.g. Node v4 and above.\nAsynchronous functions are prefixed with the <code>async</code> keyword; <code>await</code> suspends the execution until an asynchronous function return promise is fulfilled and unwraps the value from the <code>Promise</code> returned.</p>\n<h5 id=\"example-84\" style=\"position:relative;\"><a href=\"#example-84\" aria-label=\"example 84 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<p>In the following example, each input element will be printed out one at a time with a 200ms delay:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #A31515\">\"use strict\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #008000\">// printDelayed is a 'Promise&lt;void&gt;'</span>\n<span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> printDelayed(elements: string[]) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> element </span><span style=\"color: #0000FF\">of</span><span style=\"color: #000000\"> elements) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> delay(</span><span style=\"color: #09835A\">200</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">    console.log(element);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> delay(milliseconds: number) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Promise&lt;void&gt;(resolve </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    setTimeout(resolve, milliseconds);</span>\n<span style=\"color: #000000\">  });</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #000000\">printDelayed([</span><span style=\"color: #A31515\">\"Hello\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"beautiful\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"asynchronous\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"world\"</span><span style=\"color: #000000\">]).then(() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">  console.log();</span>\n<span style=\"color: #000000\">  console.log(</span><span style=\"color: #A31515\">\"Printed every element!\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">});</span></code></div></pre>\n<p>For more information see <a href=\"http://blogs.msdn.com/b/typescript/archive/2015/11/03/what-about-async-await.aspx\">Async Functions</a> blog post.</p>\n<h2 id=\"support-for---target-es6-with---module\" style=\"position:relative;\"><a href=\"#support-for---target-es6-with---module\" aria-label=\"support for   target es6 with   module permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for <code>--target ES6</code> with <code>--module</code></h2>\n<p>TypeScript 1.7 adds <code>ES6</code> to the list of options available for the <code>--module</code> flag and allows you to specify the module output when targeting <code>ES6</code>. This provides more flexibility to target exactly the features you want in specific runtimes.</p>\n<h5 id=\"example-85\" style=\"position:relative;\"><a href=\"#example-85\" aria-label=\"example 85 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"compilerOptions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"module\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"amd\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"target\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"es6\"</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"this-typing\" style=\"position:relative;\"><a href=\"#this-typing\" aria-label=\"this typing permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>this</code>-typing</h2>\n<p>It is a common pattern to return the current object (i.e. <code>this</code>) from a method to create <a href=\"https://en.wikipedia.org/wiki/Fluent_interface\">fluent-style APIs</a>.\nFor instance, consider the following <code>BasicCalculator</code> module:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">default</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> BasicCalculator {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(</span><span style=\"color: #0000FF\">protected</span><span style=\"color: #000000\"> value: number = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">) {}</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> currentValue(): number {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.value;</span>\n<span style=\"color: #000000\">  }</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> add(operand: number) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.value += operand;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> subtract(operand: number) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.value -= operand;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> multiply(operand: number) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.value *= operand;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> divide(operand: number) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.value /= operand;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>A user could express <code>2 * 5 + 1</code> as</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> calc </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./BasicCalculator\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> calc(</span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">)</span>\n<span style=\"color: #000000\">  .multiply(</span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">)</span>\n<span style=\"color: #000000\">  .add(</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">)</span>\n<span style=\"color: #000000\">  .currentValue();</span></code></div></pre>\n<p>This often opens up very elegant ways of writing code; however, there was a problem for classes that wanted to extend from <code>BasicCalculator</code>.\nImagine a user wanted to start writing a <code>ScientificCalculator</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> BasicCalculator </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./BasicCalculator\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">default</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> ScientificCalculator </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> BasicCalculator {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(value = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">super</span><span style=\"color: #000000\">(value);</span>\n<span style=\"color: #000000\">  }</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> square() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.value = </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.value ** </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> sin() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.value = Math.sin(</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.value);</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Because TypeScript used to infer the type <code>BasicCalculator</code> for each method in <code>BasicCalculator</code> that returned <code>this</code>, the type system would forget that it had <code>ScientificCalculator</code> whenever using a <code>BasicCalculator</code> method.</p>\n<p>For instance:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> calc </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./ScientificCalculator\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> calc(</span><span style=\"color: #09835A\">0.5</span><span style=\"color: #000000\">)</span>\n<span style=\"color: #000000\">  .square()</span>\n<span style=\"color: #000000\">  .divide(</span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">)</span>\n<span style=\"color: #000000\">  .sin() </span><span style=\"color: #008000\">// Error: 'BasicCalculator' has no 'sin' method.</span>\n<span style=\"color: #000000\">  .currentValue();</span></code></div></pre>\n<p>This is no longer the case - TypeScript now infers <code>this</code> to have a special type called <code>this</code> whenever inside an instance method of a class.\nThe <code>this</code> type is written as so, and basically means “the type of the left side of the dot in a method call”.</p>\n<p>The <code>this</code> type is also useful with intersection types in describing libraries (e.g. Ember.js) that use mixin-style patterns to describe inheritance:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> MyType {</span>\n<span style=\"color: #000000\">  extend&lt;T&gt;(other: T): this & T;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"es7-exponentiation-operator\" style=\"position:relative;\"><a href=\"#es7-exponentiation-operator\" aria-label=\"es7 exponentiation operator permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>ES7 exponentiation operator</h2>\n<p>TypeScript 1.7 supports upcoming <a href=\"https://github.com/rwaldron/exponentiation-operator\">ES7/ES2016 exponentiation operators</a>: <code>**</code> and <code>**=</code>. The operators will be transformed in the output to ES3/ES5 using <code>Math.pow</code>.</p>\n<h5 id=\"example-86\" style=\"position:relative;\"><a href=\"#example-86\" aria-label=\"example 86 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x = </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\"> ** </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> y = </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">y **= </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> z = -(</span><span style=\"color: #09835A\">4</span><span style=\"color: #000000\"> ** </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">);</span></code></div></pre>\n<p>Will generate the following JavaScript output:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x = Math.pow(</span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> y = </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">y = Math.pow(y, </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> z = -Math.pow(</span><span style=\"color: #09835A\">4</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">);</span></code></div></pre>\n<h2 id=\"improved-checking-for-destructuring-object-literal\" style=\"position:relative;\"><a href=\"#improved-checking-for-destructuring-object-literal\" aria-label=\"improved checking for destructuring object literal permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Improved checking for destructuring object literal</h2>\n<p>TypeScript 1.7 makes checking of destructuring patterns with an object literal or array literal initializers less rigid and more intuitive.</p>\n<p>When an object literal is contextually typed by the implied type of an object binding pattern:</p>\n<ul>\n<li>Properties with default values in the object binding pattern become optional in the object literal.</li>\n<li>Properties in the object binding pattern that have no match in the object literal are required to have a default value in the object binding pattern and are automatically added to the object literal type.</li>\n<li>Properties in the object literal that have no match in the object binding pattern are an error.</li>\n</ul>\n<p>When an array literal is contextually typed by the implied type of an array binding pattern:</p>\n<ul>\n<li>Elements in the array binding pattern that have no match in the array literal are required to have a default value in the array binding pattern and are automatically added to the array literal type.</li>\n</ul>\n<h5 id=\"example-87\" style=\"position:relative;\"><a href=\"#example-87\" aria-label=\"example 87 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Type of f1 is (arg?: { x?: number, y?: number }) =&gt; void</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f1({ x = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">, y = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\"> } = {}) {}</span>\n\n<span style=\"color: #008000\">// And can be called as:</span>\n<span style=\"color: #000000\">f1();</span>\n<span style=\"color: #000000\">f1({});</span>\n<span style=\"color: #000000\">f1({ x: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> });</span>\n<span style=\"color: #000000\">f1({ y: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> });</span>\n<span style=\"color: #000000\">f1({ x: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, y: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> });</span>\n\n<span style=\"color: #008000\">// Type of f2 is (arg?: (x: number, y?: number) =&gt; void</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f2({ x, y = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\"> } = { x: </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\"> }) {}</span>\n\n<span style=\"color: #000000\">f2();</span>\n<span style=\"color: #000000\">f2({}); </span><span style=\"color: #008000\">// Error, x not optional</span>\n<span style=\"color: #000000\">f2({ x: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> });</span>\n<span style=\"color: #000000\">f2({ y: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> }); </span><span style=\"color: #008000\">// Error, x not optional</span>\n<span style=\"color: #000000\">f2({ x: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, y: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> });</span></code></div></pre>\n<h2 id=\"support-for-decorators-when-targeting-es3\" style=\"position:relative;\"><a href=\"#support-for-decorators-when-targeting-es3\" aria-label=\"support for decorators when targeting es3 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for decorators when targeting ES3</h2>\n<p>Decorators are now allowed when targeting ES3. TypeScript 1.7 removes the ES5-specific use of <code>reduceRight</code> from the <code>__decorate</code> helper. The changes also inline calls to <code>Object.getOwnPropertyDescriptor</code> and <code>Object.defineProperty</code> in a backwards-compatible fashion that allows for clean up of the emit for ES5 and later by removing various repetitive calls to the aforementioned <code>Object</code> methods.</p>\n<h2 id=\"typescript-16\" style=\"position:relative;\"><a href=\"#typescript-16\" aria-label=\"typescript 16 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 1.6</h2>\n<h2 id=\"jsx-support\" style=\"position:relative;\"><a href=\"#jsx-support\" aria-label=\"jsx support permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>JSX support</h2>\n<p>JSX is an embeddable XML-like syntax. It is meant to be transformed into valid JavaScript, but the semantics of that transformation are implementation-specific. JSX came to popularity with the React library but has since seen other applications. TypeScript 1.6 supports embedding, type checking, and optionally compiling JSX directly into JavaScript.</p>\n<h4 id=\"new-tsx-file-extension-and-as-operator\" style=\"position:relative;\"><a href=\"#new-tsx-file-extension-and-as-operator\" aria-label=\"new tsx file extension and as operator permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New <code>.tsx</code> file extension and <code>as</code> operator</h4>\n<p>TypeScript 1.6 introduces a new <code>.tsx</code> file extension. This extension does two things: it enables JSX inside of TypeScript files, and it makes the new <code>as</code> operator the default way to cast (removing any ambiguity between JSX expressions and the TypeScript prefix cast operator). For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x = &lt;any&gt;foo;</span>\n<span style=\"color: #008000\">// is equivalent to:</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x = foo </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> any;</span></code></div></pre>\n<h4 id=\"using-react\" style=\"position:relative;\"><a href=\"#using-react\" aria-label=\"using react permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Using React</h4>\n<p>To use JSX-support with React you should use the <a href=\"https://github.com/borisyankov/DefinitelyTyped/tree/master/react\">React typings</a>. These typings define the <code>JSX</code> namespace so that TypeScript can correctly check JSX expressions for React. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">/// </span><span style=\"color: #800000\">&lt;reference</span><span style=\"color: #008000\"> </span><span style=\"color: #DC0000\">path</span><span style=\"color: #000000\">=</span><span style=\"color: #A31515\">\"react.d.ts\"</span><span style=\"color: #008000\"> </span><span style=\"color: #800000\">/&gt;</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Props {</span>\n<span style=\"color: #000000\">  name: string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> MyComponent </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> React.Component&lt;Props, {}&gt; {</span>\n<span style=\"color: #000000\">  render() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> &lt;span&gt;{</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.props.foo}&lt;/span&gt;;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #000000\">&lt;MyComponent name=</span><span style=\"color: #A31515\">\"bar\"</span><span style=\"color: #000000\"> /&gt;; </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #000000\">&lt;MyComponent name={0} /&gt;; </span><span style=\"color: #008000\">// error, `name` is not a number</span></code></div></pre>\n<h4 id=\"using-other-jsx-frameworks\" style=\"position:relative;\"><a href=\"#using-other-jsx-frameworks\" aria-label=\"using other jsx frameworks permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Using other JSX frameworks</h4>\n<p>JSX element names and properties are validated against the <code>JSX</code> namespace. Please see the [[JSX]] wiki page for defining the <code>JSX</code> namespace for your framework.</p>\n<h4 id=\"output-generation\" style=\"position:relative;\"><a href=\"#output-generation\" aria-label=\"output generation permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Output generation</h4>\n<p>TypeScript ships with two JSX modes: <code>preserve</code> and <code>react</code>.</p>\n<ul>\n<li>The <code>preserve</code> mode will keep JSX expressions as part of the output to be further consumed by another transform step. <em>Additionally the output will have a <code>.jsx</code> file extension.</em></li>\n<li>The <code>react</code> mode will emit <code>React.createElement</code>, does not need to go through a JSX transformation before use, and the output will have a <code>.js</code> file extension.</li>\n</ul>\n<p>See the [[JSX]] wiki page for more information on using JSX in TypeScript.</p>\n<h2 id=\"intersection-types\" style=\"position:relative;\"><a href=\"#intersection-types\" aria-label=\"intersection types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Intersection types</h2>\n<p>TypeScript 1.6 introduces intersection types, the logical complement of union types. A union type <code>A | B</code> represents an entity that is either of type <code>A</code> or type <code>B</code>, whereas an intersection type <code>A &#x26; B</code> represents an entity that is both of type <code>A</code> <em>and</em> type <code>B</code>.</p>\n<h5 id=\"example-88\" style=\"position:relative;\"><a href=\"#example-88\" aria-label=\"example 88 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> extend&lt;T, U&gt;(first: T, second: U): T & U {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> result = &lt;T & U&gt;{};</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> id </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> first) {</span>\n<span style=\"color: #000000\">    result[id] = first[id];</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> id </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> second) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (!result.hasOwnProperty(id)) {</span>\n<span style=\"color: #000000\">      result[id] = second[id];</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> result;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x = extend({ a: </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\"> }, { b: </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\"> });</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> s = x.a;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> n = x.b;</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> LinkedList&lt;T&gt; = T & { next: LinkedList&lt;T&gt; };</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Person {</span>\n<span style=\"color: #000000\">  name: string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> people: LinkedList&lt;Person&gt;;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> s = people.name;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> s = people.next.name;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> s = people.next.next.name;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> s = people.next.next.next.name;</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> A {</span>\n<span style=\"color: #000000\">  a: string;</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> B {</span>\n<span style=\"color: #000000\">  b: string;</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  c: string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> abc: A & B & C;</span>\n<span style=\"color: #000000\">abc.a = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">abc.b = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">abc.c = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>See <a href=\"https://github.com/Microsoft/TypeScript/issues/1256\">issue #1256</a> for more information.</p>\n<h2 id=\"local-type-declarations\" style=\"position:relative;\"><a href=\"#local-type-declarations\" aria-label=\"local type declarations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Local type declarations</h2>\n<p>Local class, interface, enum, and type alias declarations can now appear inside function declarations. Local types are block scoped, similar to variables declared with <code>let</code> and <code>const</code>. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> T {</span>\n<span style=\"color: #000000\">      x: number;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v: T;</span>\n<span style=\"color: #000000\">    v.x = </span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  } </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> T {</span>\n<span style=\"color: #000000\">      x: string;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v: T;</span>\n<span style=\"color: #000000\">    v.x = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>The inferred return type of a function may be a type declared locally within the function. It is not possible for callers of the function to reference such a local type, but it can of course be matched structurally. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Point {</span>\n<span style=\"color: #000000\">  x: number;</span>\n<span style=\"color: #000000\">  y: number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> getPointFactory(x: number, y: number) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> P {</span>\n<span style=\"color: #000000\">    x = x;</span>\n<span style=\"color: #000000\">    y = y;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> P;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> PointZero = getPointFactory(</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> PointOne = getPointFactory(</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> p1 = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> PointZero();</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> p2 = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> PointZero();</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> p3 = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> PointOne();</span></code></div></pre>\n<p>Local types may reference enclosing type parameters and local class and interfaces may themselves be generic. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f3() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f&lt;X, Y&gt;(x: X, y: Y) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> x = x;</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> y = y;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> C;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> C = f(</span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> C();</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = v.x; </span><span style=\"color: #008000\">// number</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> y = v.y; </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"class-expressions\" style=\"position:relative;\"><a href=\"#class-expressions\" aria-label=\"class expressions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Class expressions</h2>\n<p>TypeScript 1.6 adds support for ES6 class expressions. In a class expression, the class name is optional and, if specified, is only in scope in the class expression itself. This is similar to the optional name of a function expression. It is not possible to refer to the class instance type of a class expression outside the class expression, but the type can of course be matched structurally. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> Point = </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(</span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> x: number, </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> y: number) {}</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> length() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> Math.sqrt(</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.x * </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.x + </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.y * </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.y);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">};</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> p = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Point(</span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">4</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// p has anonymous class type</span>\n<span style=\"color: #000000\">console.log(p.length());</span></code></div></pre>\n<h2 id=\"extending-expressions\" style=\"position:relative;\"><a href=\"#extending-expressions\" aria-label=\"extending expressions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Extending expressions</h2>\n<p>TypeScript 1.6 adds support for classes extending arbitrary expression that computes a constructor function. This means that built-in types can now be extended in class declarations.</p>\n<p>The <code>extends</code> clause of a class previously required a type reference to be specified. It now accepts an expression optionally followed by a type argument list. The type of the expression must be a constructor function type with at least one construct signature that has the same number of type parameters as the number of type arguments specified in the <code>extends</code> clause. The return type of the matching construct signature(s) is the base type from which the class instance type inherits. Effectively, this allows both real classes and “class-like” expressions to be specified in the <code>extends</code> clause.</p>\n<p>Some examples:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Extend built-in types</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> MyArray </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Array&lt;number&gt; {}</span>\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> MyError </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Error {}</span>\n\n<span style=\"color: #008000\">// Extend computed base class</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> ThingA {</span>\n<span style=\"color: #000000\">  getGreeting() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"Hello from A\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> ThingB {</span>\n<span style=\"color: #000000\">  getGreeting() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"Hello from B\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Greeter {</span>\n<span style=\"color: #000000\">  getGreeting(): string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> GreeterConstructor {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> (): Greeter;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> getGreeterBase(): GreeterConstructor {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> Math.random() &gt;= </span><span style=\"color: #09835A\">0.5</span><span style=\"color: #000000\"> ? ThingA : ThingB;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Test </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> getGreeterBase() {</span>\n<span style=\"color: #000000\">  sayHello() {</span>\n<span style=\"color: #000000\">    console.log(</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.getGreeting());</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"abstract-classes-and-methods\" style=\"position:relative;\"><a href=\"#abstract-classes-and-methods\" aria-label=\"abstract classes and methods permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>abstract</code> classes and methods</h2>\n<p>TypeScript 1.6 adds support for <code>abstract</code> keyword for classes and their methods. An abstract class is allowed to have methods with no implementation, and cannot be constructed.</p>\n<h5 id=\"examples\" style=\"position:relative;\"><a href=\"#examples\" aria-label=\"examples permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Examples</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">abstract</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Base {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">abstract</span><span style=\"color: #000000\"> getThing(): string;</span>\n<span style=\"color: #000000\">  getOtherThing() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Base(); </span><span style=\"color: #008000\">// Error, 'Base' is abstract</span>\n\n<span style=\"color: #008000\">// Error, must either be 'abstract' or implement concrete 'getThing'</span>\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Derived1 </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Base {}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Derived2 </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Base {</span>\n<span style=\"color: #000000\">  getThing() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  foo() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">super</span><span style=\"color: #000000\">.getThing(); </span><span style=\"color: #008000\">// Error: cannot invoke abstract members through 'super'</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Derived2(); </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> y: Base = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Derived2(); </span><span style=\"color: #008000\">// Also OK</span>\n<span style=\"color: #000000\">y.getThing(); </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #000000\">y.getOtherThing(); </span><span style=\"color: #008000\">// OK</span></code></div></pre>\n<h2 id=\"generic-type-aliases\" style=\"position:relative;\"><a href=\"#generic-type-aliases\" aria-label=\"generic type aliases permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Generic type aliases</h2>\n<p>With TypeScript 1.6, type aliases can be generic. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Lazy&lt;T&gt; = T | (() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> T);</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> s: Lazy&lt;string&gt;;</span>\n<span style=\"color: #000000\">s = </span><span style=\"color: #A31515\">\"eager\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">s = () </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"lazy\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Tuple&lt;A, B&gt; {</span>\n<span style=\"color: #000000\">  a: A;</span>\n<span style=\"color: #000000\">  b: B;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Pair&lt;T&gt; = Tuple&lt;T, T&gt;;</span></code></div></pre>\n<h2 id=\"stricter-object-literal-assignment-checks\" style=\"position:relative;\"><a href=\"#stricter-object-literal-assignment-checks\" aria-label=\"stricter object literal assignment checks permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Stricter object literal assignment checks</h2>\n<p>TypeScript 1.6 enforces stricter object literal assignment checks for the purpose of catching excess or misspelled properties. Specifically, when a fresh object literal is assigned to a variable or passed as an argument for a non-empty target type, it is an error for the object literal to specify properties that don’t exist in the target type.</p>\n<h5 id=\"examples-1\" style=\"position:relative;\"><a href=\"#examples-1\" aria-label=\"examples 1 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Examples</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x: { foo: number };</span>\n<span style=\"color: #000000\">x = { foo: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, baz: </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\"> }; </span><span style=\"color: #008000\">// Error, excess property `baz`</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> y: { foo: number; bar?: number };</span>\n<span style=\"color: #000000\">y = { foo: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, baz: </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\"> }; </span><span style=\"color: #008000\">// Error, excess or misspelled property `baz`</span></code></div></pre>\n<p>A type can include an index signature to explicitly indicate that excess properties are permitted:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x: { foo: number; [x: string]: any };</span>\n<span style=\"color: #000000\">x = { foo: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, baz: </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\"> }; </span><span style=\"color: #008000\">// Ok, `baz` matched by index signature</span></code></div></pre>\n<h2 id=\"es6-generators\" style=\"position:relative;\"><a href=\"#es6-generators\" aria-label=\"es6 generators permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>ES6 generators</h2>\n<p>TypeScript 1.6 adds support for generators when targeting ES6.</p>\n<p>A generator function can have a return type annotation, just like a function. The annotation represents the type of the generator returned by the function. Here is an example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function*</span><span style=\"color: #000000\"> g(): Iterable&lt;string&gt; {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> i = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">; i &lt; </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">; i++) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">yield</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// string is assignable to string</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">yield*</span><span style=\"color: #000000\"> otherStringGenerator(); </span><span style=\"color: #008000\">// otherStringGenerator must be iterable and element type assignable to string</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>A generator function with no type annotation can have the type annotation inferred. So in the following case, the type will be inferred from the yield statements:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function*</span><span style=\"color: #000000\"> g() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> i = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">; i &lt; </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">; i++) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">yield</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// infer string</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">yield*</span><span style=\"color: #000000\"> otherStringGenerator(); </span><span style=\"color: #008000\">// infer element type of otherStringGenerator</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"experimental-support-for-async-functions\" style=\"position:relative;\"><a href=\"#experimental-support-for-async-functions\" aria-label=\"experimental support for async functions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Experimental support for <code>async</code> functions</h2>\n<p>TypeScript 1.6 introduces experimental support of <code>async</code> functions when targeting ES6. Async functions are expected to invoke an asynchronous operation and await its result without blocking normal execution of the program. This accomplished through the use of an ES6-compatible <code>Promise</code> implementation, and transposition of the function body into a compatible form to resume execution when the awaited asynchronous operation completes.</p>\n<p>An <em>async function</em> is a function or method that has been prefixed with the <code>async</code> modifier. This modifier informs the compiler that function body transposition is required, and that the keyword <code>await</code> should be treated as a unary expression instead of an identifier. An <em>Async Function</em> must provide a return type annotation that points to a compatible <code>Promise</code> type. Return type inference can only be used if there is a globally defined, compatible <code>Promise</code> type.</p>\n<h5 id=\"example-89\" style=\"position:relative;\"><a href=\"#example-89\" aria-label=\"example 89 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> p: Promise&lt;number&gt; = </span><span style=\"color: #008000\">/* ... */</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> fn(): Promise&lt;number&gt; {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> i = </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> p; </span><span style=\"color: #008000\">// suspend execution until 'p' is settled. 'i' has type \"number\"</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> + i;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> a = </span><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> (): Promise&lt;number&gt; </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> + </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> p; </span><span style=\"color: #008000\">// suspends execution.</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> a = </span><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> () </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> + </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> p; </span><span style=\"color: #008000\">// suspends execution. return type is inferred as \"Promise&lt;number&gt;\" when compiling with --target ES6</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> fe = </span><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(): Promise&lt;number&gt; {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> i = </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> p; </span><span style=\"color: #008000\">// suspend execution until 'p' is settled. 'i' has type \"number\"</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> + i;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> m(): Promise&lt;number&gt; {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> i = </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> p; </span><span style=\"color: #008000\">// suspend execution until 'p' is settled. 'i' has type \"number\"</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> + i;</span>\n<span style=\"color: #000000\">  }</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">get</span><span style=\"color: #000000\"> p(): Promise&lt;number&gt; {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> i = </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> p; </span><span style=\"color: #008000\">// suspend execution until 'p' is settled. 'i' has type \"number\"</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> + i;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"nightly-builds\" style=\"position:relative;\"><a href=\"#nightly-builds\" aria-label=\"nightly builds permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Nightly builds</h2>\n<p>While not strictly a language change, nightly builds are now available by installing with the following command:</p>\n<pre><code class=\"language-Shell\">npm install -g typescript@next\n</code></pre>\n<h2 id=\"adjustments-in-module-resolution-logic\" style=\"position:relative;\"><a href=\"#adjustments-in-module-resolution-logic\" aria-label=\"adjustments in module resolution logic permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Adjustments in module resolution logic</h2>\n<p>Starting from release 1.6 TypeScript compiler will use different set of rules to resolve module names when targeting ‘commonjs’. These <a href=\"https://github.com/Microsoft/TypeScript/issues/2338\">rules</a> attempted to model module lookup procedure used by Node. This effectively mean that node modules can include information about its typings and TypeScript compiler will be able to find it. User however can override module resolution rules picked by the compiler by using <code>--moduleResolution</code> command line option. Possible values are:</p>\n<ul>\n<li>‘classic’ - module resolution rules used by pre 1.6 TypeScript compiler</li>\n<li>‘node’ - node-like module resolution</li>\n</ul>\n<h2 id=\"merging-ambient-class-and-interface-declaration\" style=\"position:relative;\"><a href=\"#merging-ambient-class-and-interface-declaration\" aria-label=\"merging ambient class and interface declaration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Merging ambient class and interface declaration</h2>\n<p>The instance side of an ambient class declaration can be extended using an interface declaration The class constructor object is unmodified. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Foo {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> x: number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Foo {</span>\n<span style=\"color: #000000\">  y: string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> bar(foo: Foo) {</span>\n<span style=\"color: #000000\">  foo.x = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// OK, declared in the class Foo</span>\n<span style=\"color: #000000\">  foo.y = </span><span style=\"color: #A31515\">\"1\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// OK, declared in the interface Foo</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"user-defined-type-guard-functions\" style=\"position:relative;\"><a href=\"#user-defined-type-guard-functions\" aria-label=\"user defined type guard functions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>User-defined type guard functions</h2>\n<p>TypeScript 1.6 adds a new way to narrow a variable type inside an <code>if</code> block, in addition to <code>typeof</code> and <code>instanceof</code>. A user-defined type guard functions is one with a return type annotation of the form <code>x is T</code>, where <code>x</code> is a declared parameter in the signature, and <code>T</code> is any type. When a user-defined type guard function is invoked on a variable in an <code>if</code> block, the type of the variable will be narrowed to <code>T</code>.</p>\n<h5 id=\"examples-2\" style=\"position:relative;\"><a href=\"#examples-2\" aria-label=\"examples 2 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Examples</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> isCat(a: any): a </span><span style=\"color: #0000FF\">is</span><span style=\"color: #000000\"> Cat {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> a.name === </span><span style=\"color: #A31515\">\"kitty\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x: Cat | Dog;</span>\n<span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (isCat(x)) {</span>\n<span style=\"color: #000000\">  x.meow(); </span><span style=\"color: #008000\">// OK, x is Cat in this block</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"exclude-property-support-in-tsconfigjson\" style=\"position:relative;\"><a href=\"#exclude-property-support-in-tsconfigjson\" aria-label=\"exclude property support in tsconfigjson permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>exclude</code> property support in tsconfig.json</h2>\n<p>A tsconfig.json file that doesn’t specify a files property (and therefore implicitly references all *.ts files in all subdirectories) can now contain an exclude property that specifies a list of files and/or directories to exclude from the compilation. The exclude property must be an array of strings that each specify a file or folder name relative to the location of the tsconfig.json file. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"compilerOptions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"out\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"test.js\"</span>\n<span style=\"color: #000000\">  },</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"exclude\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"node_modules\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"test.ts\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"utils/t2.ts\"</span><span style=\"color: #000000\">]</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>The <code>exclude</code> list does not support wilcards. It must simply be a list of files and/or directories.</p>\n<h2 id=\"--init-command-line-option\" style=\"position:relative;\"><a href=\"#--init-command-line-option\" aria-label=\"  init command line option permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>--init</code> command line option</h2>\n<p>Run <code>tsc --init</code> in a directory to create an initial <code>tsconfig.json</code> in this directory with preset defaults. Optionally pass command line arguments along with <code>--init</code> to be stored in your initial tsconfig.json on creation.</p>\n<h2 id=\"typescript-15\" style=\"position:relative;\"><a href=\"#typescript-15\" aria-label=\"typescript 15 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 1.5</h2>\n<h2 id=\"es6-modules\" style=\"position:relative;\"><a href=\"#es6-modules\" aria-label=\"es6 modules permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>ES6 Modules</h2>\n<p>TypeScript 1.5 supports ECMAScript 6 (ES6) modules. ES6 modules are effectively TypeScript external modules with a new syntax: ES6 modules are separately loaded source files that possibly import other modules and provide a number of externally accessible exports. ES6 modules feature several new export and import declarations. It is recommended that TypeScript libraries and applications be updated to use the new syntax, but this is not a requirement. The new ES6 module syntax coexists with TypeScript’s original internal and external module constructs and the constructs can be mixed and matched at will.</p>\n<h4 id=\"export-declarations\" style=\"position:relative;\"><a href=\"#export-declarations\" aria-label=\"export declarations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Export Declarations</h4>\n<p>In addition to the existing TypeScript support for decorating declarations with <code>export</code>, module members can also be exported using separate export declarations, optionally specifying different names for exports using <code>as</code> clauses.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Stream { ... }</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> writeToStream(stream: Stream, data: string) { ... }</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> { Stream, writeToStream </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> write };  </span><span style=\"color: #008000\">// writeToStream exported as write</span></code></div></pre>\n<p>Import declarations, as well, can optionally use <code>as</code> clauses to specify different local names for the imports. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> { read, write, standardOutput </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> stdout } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./inout\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> s = read(stdout);</span>\n<span style=\"color: #000000\">write(stdout, s);</span></code></div></pre>\n<p>As an alternative to individual imports, a namespace import can be used to import an entire module:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">*</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> io </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./inout\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> s = io.read(io.standardOutput);</span>\n<span style=\"color: #000000\">io.write(io.standardOutput, s);</span></code></div></pre>\n<h4 id=\"re-exporting\" style=\"position:relative;\"><a href=\"#re-exporting\" aria-label=\"re exporting permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Re-exporting</h4>\n<p>Using <code>from</code> clause a module can copy the exports of a given module to the current module without introducing local names.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> { read, write, standardOutput </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> stdout } </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./inout\"</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p><code>export *</code> can be used to re-export all exports of another module. This is useful for creating modules that aggregate the exports of several other modules.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> transform(s: string): string { ... }</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">*</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./mod1\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">*</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./mod2\"</span><span style=\"color: #000000\">;</span></code></div></pre>\n<h4 id=\"default-export\" style=\"position:relative;\"><a href=\"#default-export\" aria-label=\"default export permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Default Export</h4>\n<p>An export default declaration specifies an expression that becomes the default export of a module:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">default</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Greeter {</span>\n<span style=\"color: #000000\">  sayHello() {</span>\n<span style=\"color: #000000\">    console.log(</span><span style=\"color: #A31515\">\"Greetings!\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Which in turn can be imported using default imports:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> Greeter </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./greeter\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> g = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Greeter();</span>\n<span style=\"color: #000000\">g.sayHello();</span></code></div></pre>\n<h4 id=\"bare-import\" style=\"position:relative;\"><a href=\"#bare-import\" aria-label=\"bare import permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Bare Import</h4>\n<p>A “bare import” can be used to import a module only for its side-effects.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./polyfills\"</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>For more information about module, please see the <a href=\"https://github.com/Microsoft/TypeScript/issues/2242\">ES6 module support spec</a>.</p>\n<h2 id=\"destructuring-in-declarations-and-assignments\" style=\"position:relative;\"><a href=\"#destructuring-in-declarations-and-assignments\" aria-label=\"destructuring in declarations and assignments permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Destructuring in declarations and assignments</h2>\n<p>TypeScript 1.5 adds support to ES6 destructuring declarations and assignments.</p>\n<h4 id=\"declarations\" style=\"position:relative;\"><a href=\"#declarations\" aria-label=\"declarations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Declarations</h4>\n<p>A destructuring declaration introduces one or more named variables and initializes them with values extracted from properties of an object or elements of an array.</p>\n<p>For example, the following sample declares variables <code>x</code>, <code>y</code>, and <code>z</code>, and initializes them to <code>getSomeObject().x</code>, <code>getSomeObject().y</code> and <code>getSomeObject().z</code> respectively:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> { x, y, z } = getSomeObject();</span></code></div></pre>\n<p>Destructuring declarations also works for extracting values from arrays:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> [x, y, z = </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">] = getSomeArray();</span></code></div></pre>\n<p>Similarly, destructuring can be used in function parameter declarations:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> drawText({ text = </span><span style=\"color: #A31515\">\"\"</span><span style=\"color: #000000\">, location: [x, y] = [</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">], bold = </span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\"> }) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// Draw text</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Call drawText with an object literal</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> item = { text: </span><span style=\"color: #A31515\">\"someText\"</span><span style=\"color: #000000\">, location: [</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">], style: </span><span style=\"color: #A31515\">\"italics\"</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #000000\">drawText(item);</span></code></div></pre>\n<h4 id=\"assignments\" style=\"position:relative;\"><a href=\"#assignments\" aria-label=\"assignments permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Assignments</h4>\n<p>Destructuring patterns can also be used in regular assignment expressions. For instance, swapping two variables can be written as a single destructuring assignment:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> y = </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">[x, y] = [y, x];</span></code></div></pre>\n<h2 id=\"namespace-keyword\" style=\"position:relative;\"><a href=\"#namespace-keyword\" aria-label=\"namespace keyword permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>namespace</code> keyword</h2>\n<p>TypeScript used the <code>module</code> keyword to define both “internal modules” and “external modules”; this has been a bit of confusion for developers new to TypeScript. “Internal modules” are closer to what most people would call a namespace; likewise, “external modules” in JS speak really just are modules now.</p>\n<blockquote>\n<p>Note: Previous syntax defining internal modules are still supported.</p>\n</blockquote>\n<p><strong>Before</strong>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">module</span><span style=\"color: #000000\"> Math {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> add(x, y) { ... }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p><strong>After</strong>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">namespace</span><span style=\"color: #000000\"> Math {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> add(x, y) { ... }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"let-and-const-support\" style=\"position:relative;\"><a href=\"#let-and-const-support\" aria-label=\"let and const support permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>let</code> and <code>const</code> support</h2>\n<p>ES6 <code>let</code> and <code>const</code> declarations are now supported when targeting ES3 and ES5.</p>\n<h4 id=\"const\" style=\"position:relative;\"><a href=\"#const\" aria-label=\"const permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Const</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> MAX = </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #000000\">++MAX; </span><span style=\"color: #008000\">// Error: The operand of an increment or decrement</span>\n<span style=\"color: #008000\">//        operator cannot be a constant.</span></code></div></pre>\n<h4 id=\"block-scoped\" style=\"position:relative;\"><a href=\"#block-scoped\" aria-label=\"block scoped permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Block scoped</h4>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> a = </span><span style=\"color: #09835A\">4</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// use a</span>\n<span style=\"color: #000000\">} </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> a = </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// use a</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #000000\">alert(a); </span><span style=\"color: #008000\">// Error: a is not defined in this scope</span></code></div></pre>\n<h2 id=\"forof-support\" style=\"position:relative;\"><a href=\"#forof-support\" aria-label=\"forof support permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>for..of support</h2>\n<p>TypeScript 1.5 adds support to ES6 for..of loops on arrays for ES3/ES5 as well as full support for Iterator interfaces when targetting ES6.</p>\n<h5 id=\"example-90\" style=\"position:relative;\"><a href=\"#example-90\" aria-label=\"example 90 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<p>The TypeScript compiler will transpile for..of arrays to idiomatic ES3/ES5 JavaScript when targeting those versions:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> v </span><span style=\"color: #0000FF\">of</span><span style=\"color: #000000\"> expr) {</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>will be emitted as:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> _i = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">, _a = expr; _i &lt; _a.length; _i++) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> v = _a[_i];</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"decorators\" style=\"position:relative;\"><a href=\"#decorators\" aria-label=\"decorators permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Decorators</h2>\n<blockquote>\n<p>TypeScript decorators are based on the <a href=\"https://github.com/wycats/javascript-decorators\">ES7 decorator proposal</a>.</p>\n</blockquote>\n<p>A decorator is:</p>\n<ul>\n<li>an expression</li>\n<li>that evaluates to a function</li>\n<li>that takes the target, name, and property descriptor as arguments</li>\n<li>and optionally returns a property descriptor to install on the target object</li>\n</ul>\n<blockquote>\n<p>For more information, please see the <a href=\"https://github.com/Microsoft/TypeScript/issues/2249\">Decorators</a> proposal.</p>\n</blockquote>\n<h5 id=\"example-91\" style=\"position:relative;\"><a href=\"#example-91\" aria-label=\"example 91 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<p>Decorators <code>readonly</code> and <code>enumerable(false)</code> will be applied to the property <code>method</code> before it is installed on class <code>C</code>. This allows the decorator to change the implementation, and in this case, augment the descriptor to be writable: false and enumerable: false.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  @readonly</span>\n<span style=\"color: #000000\">  @enumerable(</span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\">)</span>\n<span style=\"color: #000000\">  method() {}</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> readonly(target, key, descriptor) {</span>\n<span style=\"color: #000000\">  descriptor.writable = </span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> enumerable(value) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(target, key, descriptor) {</span>\n<span style=\"color: #000000\">    descriptor.enumerable = value;</span>\n<span style=\"color: #000000\">  };</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"computed-properties\" style=\"position:relative;\"><a href=\"#computed-properties\" aria-label=\"computed properties permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Computed properties</h2>\n<p>Initializing an object with dynamic properties can be a bit of a burden. Take the following example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> NeighborMap = { [name: string]: Node };</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Node = { name: string; neighbors: NeighborMap };</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> makeNode(name: string, initialNeighbor: Node): Node {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> neighbors: NeighborMap = {};</span>\n<span style=\"color: #000000\">  neighbors[initialNeighbor.name] = initialNeighbor;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> { name: name, neighbors: neighbors };</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Here we need to create a variable to hold on to the neighbor-map so that we can initialize it. With TypeScript 1.5, we can let the compiler do the heavy lifting:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> makeNode(name: string, initialNeighbor: Node): Node {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    name: name,</span>\n<span style=\"color: #000000\">    neighbors: {</span>\n<span style=\"color: #000000\">      [initialNeighbor.name]: initialNeighbor</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">  };</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"support-for-umd-and-system-module-output\" style=\"position:relative;\"><a href=\"#support-for-umd-and-system-module-output\" aria-label=\"support for umd and system module output permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for <code>UMD</code> and <code>System</code> module output</h2>\n<p>In addition to <code>AMD</code> and <code>CommonJS</code> module loaders, TypeScript now supports emitting modules <code>UMD</code> (<a href=\"https://github.com/umdjs/umd\">Universal Module Definition</a>) and <a href=\"https://github.com/systemjs/systemjs\"><code>System</code></a> module formats.</p>\n<p><strong>Usage</strong>:</p>\n<blockquote>\n<p>tsc —module umd</p>\n</blockquote>\n<p>and</p>\n<blockquote>\n<p>tsc —module system</p>\n</blockquote>\n<h2 id=\"unicode-codepoint-escapes-in-strings\" style=\"position:relative;\"><a href=\"#unicode-codepoint-escapes-in-strings\" aria-label=\"unicode codepoint escapes in strings permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Unicode codepoint escapes in strings</h2>\n<p>ES6 introduces escapes that allow users to represent a Unicode codepoint using just a single escape.</p>\n<p>As an example, consider the need to escape a string that contains the character ’𠮷‘. In UTF-16/UCS2, ’𠮷’ is represented as a surrogate pair, meaning that it’s encoded using a pair of 16-bit code units of values, specifically <code>0xD842</code> and <code>0xDFB7</code>. Previously this meant that you’d have to escape the codepoint as <code>\"\\uD842\\uDFB7\"</code>. This has the major downside that it’s difficult to discern two independent characters from a surrogate pair.</p>\n<p>With ES6’s codepoint escapes, you can cleanly represent that exact character in strings and template strings with a single escape: <code>\"\\u{20bb7}\"</code>. TypeScript will emit the string in ES3/ES5 as <code>\"\\uD842\\uDFB7\"</code>.</p>\n<h2 id=\"tagged-template-strings-in-es3es5\" style=\"position:relative;\"><a href=\"#tagged-template-strings-in-es3es5\" aria-label=\"tagged template strings in es3es5 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Tagged template strings in ES3/ES5</h2>\n<p>In TypeScript 1.4, we added support for template strings for all targets, and tagged templates for just ES6. Thanks to some considerable work done by <a href=\"https://github.com/ivogabe\">@ivogabe</a>, we bridged the gap for for tagged templates in ES3 and ES5.</p>\n<p>When targeting ES3/ES5, the following code</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> oddRawStrings(strs: TemplateStringsArray, n1, n2) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> strs.raw.filter((raw, index) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> index % </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\"> === </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #A31515\">oddRawStrings`Hello \\n</span><span style=\"color: #0000FF\">${</span><span style=\"color: #09835A\">123</span><span style=\"color: #0000FF\">}</span><span style=\"color: #A31515\"> \\t </span><span style=\"color: #0000FF\">${</span><span style=\"color: #09835A\">456</span><span style=\"color: #0000FF\">}</span><span style=\"color: #A31515\">\\n world`</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>will be emitted as</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> oddRawStrings(strs, n1, n2) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> strs.raw.filter(</span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(raw, index) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> index % </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\"> === </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  });</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #000000\">(_a = [</span><span style=\"color: #A31515\">\"Hello \\n\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\" \\t \"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"\\n world\"</span><span style=\"color: #000000\">]),</span>\n<span style=\"color: #000000\">  (_a.raw = [</span><span style=\"color: #A31515\">\"Hello \\\\n\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\" \\\\t \"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"\\\\n world\"</span><span style=\"color: #000000\">]),</span>\n<span style=\"color: #000000\">  oddRawStrings(_a, </span><span style=\"color: #09835A\">123</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">456</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> _a;</span></code></div></pre>\n<h2 id=\"amd-dependency-optional-names\" style=\"position:relative;\"><a href=\"#amd-dependency-optional-names\" aria-label=\"amd dependency optional names permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>AMD-dependency optional names</h2>\n<p><code>/// &#x3C;amd-dependency path=\"x\" /></code> informs the compiler about a non-TS module dependency that needs to be injected in the resulting module’s require call; however, there was no way to consume this module in the TS code.</p>\n<p>The new <code>amd-dependency name</code> property allows passing an optional name for an amd-dependency:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">/// </span><span style=\"color: #800000\">&lt;amd-dependency</span><span style=\"color: #008000\"> </span><span style=\"color: #DC0000\">path</span><span style=\"color: #000000\">=</span><span style=\"color: #A31515\">\"legacy/moduleA\"</span><span style=\"color: #008000\"> </span><span style=\"color: #DC0000\">name</span><span style=\"color: #000000\">=</span><span style=\"color: #A31515\">\"moduleA\"</span><span style=\"color: #800000\">/&gt;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> moduleA: MyType;</span>\n<span style=\"color: #000000\">moduleA.callStuff();</span></code></div></pre>\n<p>Generated JS code:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #000000\">define([</span><span style=\"color: #A31515\">\"require\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"exports\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"legacy/moduleA\"</span><span style=\"color: #000000\">], </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(</span>\n<span style=\"color: #000000\">  require,</span>\n<span style=\"color: #000000\">  exports,</span>\n<span style=\"color: #000000\">  moduleA</span>\n<span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">  moduleA.callStuff();</span>\n<span style=\"color: #000000\">});</span></code></div></pre>\n<h2 id=\"project-support-through-tsconfigjson\" style=\"position:relative;\"><a href=\"#project-support-through-tsconfigjson\" aria-label=\"project support through tsconfigjson permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Project support through <code>tsconfig.json</code></h2>\n<p>Adding a <code>tsconfig.json</code> file in a directory indicates that the directory is the root of a TypeScript project. The tsconfig.json file specifies the root files and the compiler options required to compile the project. A project is compiled in one of the following ways:</p>\n<ul>\n<li>By invoking tsc with no input files, in which case the compiler searches for the tsconfig.json file starting in the current directory and continuing up the parent directory chain.</li>\n<li>By invoking tsc with no input files and a -project (or just -p) command line option that specifies the path of a directory containing a tsconfig.json file.</li>\n</ul>\n<h5 id=\"example-92\" style=\"position:relative;\"><a href=\"#example-92\" aria-label=\"example 92 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"compilerOptions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"module\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"commonjs\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"noImplicitAny\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"sourceMap\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>See the <a href=\"https://github.com/Microsoft/TypeScript/wiki/tsconfig.json\">tsconfig.json wiki page</a> for more details.</p>\n<h2 id=\"--rootdir-command-line-option\" style=\"position:relative;\"><a href=\"#--rootdir-command-line-option\" aria-label=\"  rootdir command line option permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>--rootDir</code> command line option</h2>\n<p>Option <code>--outDir</code> duplicates the input hierarchy in the output. The compiler computes the root of the input files as the longest common path of all input files; and then uses that to replicate all its substructure in the output.</p>\n<p>Sometimes this is not desirable, for instance inputs <code>FolderA/FolderB/1.ts</code> and <code>FolderA/FolderB/2.ts</code> would result in output structure mirroring <code>FolderA/FolderB/</code>. Now if a new file <code>FolderA/3.ts</code> is added to the input, the output structure will pop out to mirror <code>FolderA/</code>.</p>\n<p><code>--rootDir</code> specifies the input directory to be mirrored in output instead of computing it.</p>\n<h2 id=\"--noemithelpers-command-line-option\" style=\"position:relative;\"><a href=\"#--noemithelpers-command-line-option\" aria-label=\"  noemithelpers command line option permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>--noEmitHelpers</code> command line option</h2>\n<p>The TypeScript compiler emits a few helpers like <code>__extends</code> when needed. The helpers are emitted in every file they are referenced in. If you want to consolidate all helpers in one place, or override the default behavior, use <code>--noEmitHelpers</code> to instructs the compiler not to emit them.</p>\n<h2 id=\"--newline-command-line-option\" style=\"position:relative;\"><a href=\"#--newline-command-line-option\" aria-label=\"  newline command line option permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>--newLine</code> command line option</h2>\n<p>By default the output new line character is <code>\\r\\n</code> on Windows based systems and <code>\\n</code> on *nix based systems. <code>--newLine</code> command line flag allows overriding this behavior and specifying the new line character to be used in generated output files.</p>\n<h2 id=\"--inlinesourcemap-and-inlinesources-command-line-options\" style=\"position:relative;\"><a href=\"#--inlinesourcemap-and-inlinesources-command-line-options\" aria-label=\"  inlinesourcemap and inlinesources command line options permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>--inlineSourceMap</code> and <code>inlineSources</code> command line options</h2>\n<p><code>--inlineSourceMap</code> causes source map files to be written inline in the generated <code>.js</code> files instead of in a independent <code>.js.map</code> file. <code>--inlineSources</code> allows for additionally inlining the source <code>.ts</code> file into the</p>\n<h2 id=\"typescript-14\" style=\"position:relative;\"><a href=\"#typescript-14\" aria-label=\"typescript 14 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 1.4</h2>\n<h2 id=\"union-types\" style=\"position:relative;\"><a href=\"#union-types\" aria-label=\"union types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Union types</h2>\n<h3 id=\"overview\" style=\"position:relative;\"><a href=\"#overview\" aria-label=\"overview permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Overview</h3>\n<p>Union types are a powerful way to express a value that can be one of several types. For example, you might have an API for running a program that takes a commandline as either a <code>string</code>, a <code>string[]</code> or a function that returns a <code>string</code>. You can now write:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> RunOptions {</span>\n<span style=\"color: #000000\">  program: string;</span>\n<span style=\"color: #000000\">  commandline: string[] | string | (() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> string);</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Assignment to union types works very intuitively — anything you could assign to one of the union type’s members is assignable to the union:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> opts: RunOptions = </span><span style=\"color: #008000\">/* ... */</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">opts.commandline = </span><span style=\"color: #A31515\">'-hello world'</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #000000\">opts.commandline = [</span><span style=\"color: #A31515\">'-hello'</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">'world'</span><span style=\"color: #000000\">]; </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #000000\">opts.commandline = [</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">]; </span><span style=\"color: #008000\">// Error, number is not string or string[]</span></code></div></pre>\n<p>When reading from a union type, you can see any properties that are shared by them:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (opts.length === </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// OK, string and string[] both have 'length' property</span>\n<span style=\"color: #000000\">  console.log(</span><span style=\"color: #A31515\">\"it's empty\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Using Type Guards, you can easily work with a variable of a union type:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> formatCommandline(c: string | string[]) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> c === </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> c.trim();</span>\n<span style=\"color: #000000\">  } </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> c.join(</span><span style=\"color: #A31515\">\" \"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h3 id=\"stricter-generics\" style=\"position:relative;\"><a href=\"#stricter-generics\" aria-label=\"stricter generics permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Stricter Generics</h3>\n<p>With union types able to represent a wide range of type scenarios, we’ve decided to improve the strictness of certain generic calls. Previously, code like this would (surprisingly) compile without error:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> equal&lt;T&gt;(lhs: T, rhs: T): boolean {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> lhs === rhs;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Previously: No error</span>\n<span style=\"color: #008000\">// New behavior: Error, no best common type between 'string' and 'number'</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> e = equal(</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">);</span></code></div></pre>\n<p>With union types, you can now specify the desired behavior at both the function declaration site and the call site:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// 'choose' function where types must match</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> choose1&lt;T&gt;(a: T, b: T): T {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> Math.random() &gt; </span><span style=\"color: #09835A\">0.5</span><span style=\"color: #000000\"> ? a : b;</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> a = choose1(</span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> b = choose1&lt;string | number&gt;(</span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// OK</span>\n\n<span style=\"color: #008000\">// 'choose' function where types need not match</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> choose2&lt;T, U&gt;(a: T, b: U): T | U {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> Math.random() &gt; </span><span style=\"color: #09835A\">0.5</span><span style=\"color: #000000\"> ? a : b;</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> c = choose2(</span><span style=\"color: #A31515\">\"bar\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"foo\"</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// OK, c: string</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> d = choose2(</span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// OK, d: string|number</span></code></div></pre>\n<h3 id=\"better-type-inference\" style=\"position:relative;\"><a href=\"#better-type-inference\" aria-label=\"better type inference permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Better Type Inference</h3>\n<p>Union types also allow for better type inference in arrays and other places where you might have multiple kinds of values in a collection:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x = [</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">]; </span><span style=\"color: #008000\">// x: Array&lt;string|number&gt;</span>\n<span style=\"color: #000000\">x[</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">] = </span><span style=\"color: #A31515\">\"world\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #000000\">x[</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">] = </span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error, boolean is not string or number</span></code></div></pre>\n<h2 id=\"let-declarations\" style=\"position:relative;\"><a href=\"#let-declarations\" aria-label=\"let declarations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>let</code> declarations</h2>\n<p>In JavaScript, <code>var</code> declarations are “hoisted” to the top of their enclosing scope. This can result in confusing bugs:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #000000\">console.log(x); </span><span style=\"color: #008000\">// meant to write 'y' here</span>\n<span style=\"color: #008000\">/* later in the same block */</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>The new ES6 keyword <code>let</code>, now supported in TypeScript, declares a variable with more intuitive “block” semantics. A <code>let</code> variable can only be referred to after its declaration, and is scoped to the syntactic block where it is defined:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (foo) {</span>\n<span style=\"color: #000000\">  console.log(x); </span><span style=\"color: #008000\">// Error, cannot refer to x before its declaration</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">} </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">  console.log(x); </span><span style=\"color: #008000\">// Error, x is not declared in this block</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p><code>let</code> is only available when targeting ECMAScript 6 (<code>--target ES6</code>).</p>\n<h2 id=\"const-declarations\" style=\"position:relative;\"><a href=\"#const-declarations\" aria-label=\"const declarations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>const</code> declarations</h2>\n<p>The other new ES6 declaration type supported in TypeScript is <code>const</code>. A <code>const</code> variable may not be assigned to, and must be initialized where it is declared. This is useful for declarations where you don’t want to change the value after its initialization:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> halfPi = Math.PI / </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">halfPi = </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error, can't assign to a `const`</span></code></div></pre>\n<p><code>const</code> is only available when targeting ECMAScript 6 (<code>--target ES6</code>).</p>\n<h2 id=\"template-strings\" style=\"position:relative;\"><a href=\"#template-strings\" aria-label=\"template strings permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Template strings</h2>\n<p>TypeScript now supports ES6 template strings. These are an easy way to embed arbitrary expressions in strings:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> name = </span><span style=\"color: #A31515\">\"TypeScript\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> greeting = </span><span style=\"color: #A31515\">`Hello, </span><span style=\"color: #0000FF\">${</span><span style=\"color: #A31515\">name</span><span style=\"color: #0000FF\">}</span><span style=\"color: #A31515\">! Your name has </span><span style=\"color: #0000FF\">${</span><span style=\"color: #A31515\">name.length</span><span style=\"color: #0000FF\">}</span><span style=\"color: #A31515\"> characters`</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>When compiling to pre-ES6 targets, the string is decomposed:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> name = </span><span style=\"color: #A31515\">\"TypeScript!\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> greeting =</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #A31515\">\"Hello, \"</span><span style=\"color: #000000\"> + name + </span><span style=\"color: #A31515\">\"! Your name has \"</span><span style=\"color: #000000\"> + name.length + </span><span style=\"color: #A31515\">\" characters\"</span><span style=\"color: #000000\">;</span></code></div></pre>\n<h2 id=\"type-guards\" style=\"position:relative;\"><a href=\"#type-guards\" aria-label=\"type guards permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Type Guards</h2>\n<p>A common pattern in JavaScript is to use <code>typeof</code> or <code>instanceof</code> to examine the type of an expression at runtime. TypeScript now understands these conditions and will change type inference accordingly when used in an <code>if</code> block.</p>\n<p>Using <code>typeof</code> to test a variable:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x: any = </span><span style=\"color: #008000\">/* ... */</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">if</span><span style=\"color: #000000\">(</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> x === </span><span style=\"color: #A31515\">'string'</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    console.log(x.subtr(</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">)); </span><span style=\"color: #008000\">// Error, 'subtr' does not exist on 'string'</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #008000\">// x is still any here</span>\n<span style=\"color: #000000\">x.unknown(); </span><span style=\"color: #008000\">// OK</span></code></div></pre>\n<p>Using <code>typeof</code> with union types and <code>else</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x: string | HTMLElement = </span><span style=\"color: #008000\">/* ... */</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">if</span><span style=\"color: #000000\">(</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> x === </span><span style=\"color: #A31515\">'string'</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// x is string here, as shown above</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// x is HTMLElement here</span>\n<span style=\"color: #000000\">    console.log(x.innerHTML);</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Using <code>instanceof</code> with classes and union types:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Dog { woof() { } }</span>\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Cat { meow() { } }</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> pet: Dog|Cat = </span><span style=\"color: #008000\">/* ... */</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (pet </span><span style=\"color: #0000FF\">instanceof</span><span style=\"color: #000000\"> Dog) {</span>\n<span style=\"color: #000000\">    pet.woof(); </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    pet.woof(); </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"type-aliases\" style=\"position:relative;\"><a href=\"#type-aliases\" aria-label=\"type aliases permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Type Aliases</h2>\n<p>You can now define an <em>alias</em> for a type using the <code>type</code> keyword:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> PrimitiveArray = Array&lt;string | number | boolean&gt;;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> MyNumber = number;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> NgScope = ng.IScope;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Callback = () </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void;</span></code></div></pre>\n<p>Type aliases are exactly the same as their original types; they are simply alternative names.</p>\n<h2 id=\"const-enum-completely-inlined-enums\" style=\"position:relative;\"><a href=\"#const-enum-completely-inlined-enums\" aria-label=\"const enum completely inlined enums permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>const enum</code> (completely inlined enums)</h2>\n<p>Enums are very useful, but some programs don’t actually need the generated code and would benefit from simply inlining all instances of enum members with their numeric equivalents. The new <code>const enum</code> declaration works just like a regular <code>enum</code> for type safety, but erases completely at compile time.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">enum</span><span style=\"color: #000000\"> Suit {</span>\n<span style=\"color: #000000\">  Clubs,</span>\n<span style=\"color: #000000\">  Diamonds,</span>\n<span style=\"color: #000000\">  Hearts,</span>\n<span style=\"color: #000000\">  Spades</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> d = Suit.Diamonds;</span></code></div></pre>\n<p>Compiles to exactly:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> d = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>TypeScript will also now compute enum values when possible:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">enum</span><span style=\"color: #000000\"> MyFlags {</span>\n<span style=\"color: #000000\">  None = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  Neat = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  Cool = </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  Awesome = </span><span style=\"color: #09835A\">4</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  Best = Neat | Cool | Awesome</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> b = MyFlags.Best; </span><span style=\"color: #008000\">// emits var b = 7;</span></code></div></pre>\n<h2 id=\"-noemitonerror-commandline-option\" style=\"position:relative;\"><a href=\"#-noemitonerror-commandline-option\" aria-label=\" noemitonerror commandline option permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>-noEmitOnError</code> commandline option</h2>\n<p>The default behavior for the TypeScript compiler is to still emit .js files if there were type errors (for example, an attempt to assign a <code>string</code> to a <code>number</code>). This can be undesirable on build servers or other scenarios where only output from a “clean” build is desired. The new flag <code>noEmitOnError</code> prevents the compiler from emitting .js code if there were any errors.</p>\n<p>This is now the default for MSBuild projects; this allows MSBuild incremental build to work as expected, as outputs are only generated on clean builds.</p>\n<h2 id=\"amd-module-names\" style=\"position:relative;\"><a href=\"#amd-module-names\" aria-label=\"amd module names permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>AMD Module names</h2>\n<p>By default AMD modules are generated anonymous. This can lead to problems when other tools are used to process the resulting modules like a bundler (e.g. <code>r.js</code>).</p>\n<p>The new <code>amd-module name</code> tag allows passing an optional module name to the compiler:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">//// [amdModule.ts]</span>\n<span style=\"color: #008000\">///</span><span style=\"color: #800000\">&lt;amd-module</span><span style=\"color: #008000\"> </span><span style=\"color: #DC0000\">name</span><span style=\"color: #000000\">=</span><span style=\"color: #A31515\">'NamedModule'</span><span style=\"color: #800000\">/&gt;</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {}</span></code></div></pre>\n<p>Will result in assigning the name <code>NamedModule</code> to the module as part of calling the AMD <code>define</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #008000\">//// [amdModule.js]</span>\n<span style=\"color: #000000\">define(</span><span style=\"color: #A31515\">\"NamedModule\"</span><span style=\"color: #000000\">, [</span><span style=\"color: #A31515\">\"require\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"exports\"</span><span style=\"color: #000000\">], </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(require, exports) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> C = (</span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> C() {}</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> C;</span>\n<span style=\"color: #000000\">  })();</span>\n<span style=\"color: #000000\">  exports.C = C;</span>\n<span style=\"color: #000000\">});</span></code></div></pre>\n<h2 id=\"typescript-13\" style=\"position:relative;\"><a href=\"#typescript-13\" aria-label=\"typescript 13 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 1.3</h2>\n<h2 id=\"protected\" style=\"position:relative;\"><a href=\"#protected\" aria-label=\"protected permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Protected</h2>\n<p>The new <code>protected</code> modifier in classes works like it does in familiar languages like C++, C#, and Java. A <code>protected</code> member of a class is visible only inside subclasses of the class in which it is declared:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Thing {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">protected</span><span style=\"color: #000000\"> doSomething() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">/* ... */</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> MyThing </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Thing {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> myMethod() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// OK, can access protected member from subclass</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.doSomething();</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> t = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> MyThing();</span>\n<span style=\"color: #000000\">t.doSomething(); </span><span style=\"color: #008000\">// Error, cannot call protected member from outside class</span></code></div></pre>\n<h2 id=\"tuple-types\" style=\"position:relative;\"><a href=\"#tuple-types\" aria-label=\"tuple types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Tuple types</h2>\n<p>Tuple types express an array where the type of certain elements is known, but need not be the same. For example, you may want to represent an array with a <code>string</code> at position 0 and a <code>number</code> at position 1:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Declare a tuple type</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x: [string, number];</span>\n<span style=\"color: #008000\">// Initialize it</span>\n<span style=\"color: #000000\">x = [</span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">]; </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #008000\">// Initialize it incorrectly</span>\n<span style=\"color: #000000\">x = [</span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">]; </span><span style=\"color: #008000\">// Error</span></code></div></pre>\n<p>When accessing an element with a known index, the correct type is retrieved:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #000000\">console.log(x[</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">].substr(</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">)); </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #000000\">console.log(x[</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">].substr(</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">)); </span><span style=\"color: #008000\">// Error, 'number' does not have 'substr'</span></code></div></pre>\n<p>Note that in TypeScript 1.4, when accessing an element outside the set of known indices, a union type is used instead:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #000000\">x[</span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">] = </span><span style=\"color: #A31515\">\"world\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #000000\">console.log(x[</span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">].toString()); </span><span style=\"color: #008000\">// OK, 'string' and 'number' both have toString</span>\n<span style=\"color: #000000\">x[</span><span style=\"color: #09835A\">6</span><span style=\"color: #000000\">] = </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// Error, boolean isn't number or string</span></code></div></pre>\n<h2 id=\"typescript-11\" style=\"position:relative;\"><a href=\"#typescript-11\" aria-label=\"typescript 11 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TypeScript 1.1</h2>\n<h2 id=\"performance-improvements\" style=\"position:relative;\"><a href=\"#performance-improvements\" aria-label=\"performance improvements permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Performance Improvements</h2>\n<p>The 1.1 compiler is typically around 4x faster than any previous release. See <a href=\"http://blogs.msdn.com/b/typescript/archive/2014/10/06/announcing-typescript-1-1-ctp.aspx\">this blog post for some impressive charts.</a></p>\n<h2 id=\"better-module-visibility-rules\" style=\"position:relative;\"><a href=\"#better-module-visibility-rules\" aria-label=\"better module visibility rules permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Better Module Visibility Rules</h2>\n<p>TypeScript now only strictly enforces the visibility of types in modules if the <code>--declaration</code> flag is provided. This is very useful for Angular scenarios, for example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">module</span><span style=\"color: #000000\"> MyControllers {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> ZooScope </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> ng.IScope {</span>\n<span style=\"color: #000000\">    animals: Animal[];</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> ZooController {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// Used to be an error (cannot expose ZooScope), but now is only</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// an error when trying to generate .d.ts files</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(</span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> $scope: ZooScope) {}</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">/* more code */</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>","headings":[{"value":"TypeScript 3.8","depth":1},{"value":"Type-Only Imports and Export","depth":2},{"value":"ECMAScript Private Fields","depth":2},{"value":"Which should I use?","depth":3},{"value":"export * as ns Syntax","depth":2},{"value":"<span id=\"top-level-await\" /> Top-Level await","depth":2},{"value":"es2020 for target and module","depth":2},{"value":"JSDoc Property Modifiers","depth":2},{"value":"Better Directory Watching on Linux and watchOptions","depth":2},{"value":"“Fast and Loose” Incremental Checking","depth":2},{"value":"TypeScript 3.7","depth":1},{"value":"Optional Chaining","depth":2},{"value":"Nullish Coalescing","depth":2},{"value":"Assertion Functions","depth":2},{"value":"Better Support for never-Returning Functions","depth":2},{"value":"(More) Recursive Type Aliases","depth":2},{"value":"--declaration and --allowJs","depth":2},{"value":"The useDefineForClassFields Flag and The declare Property Modifier","depth":2},{"value":"Build-Free Editing with Project References","depth":2},{"value":"Uncalled Function Checks","depth":2},{"value":"// @ts-nocheck in TypeScript Files","depth":2},{"value":"Semicolon Formatter Option","depth":2},{"value":"3.7 Breaking Changes","depth":2},{"value":"DOM Changes","depth":3},{"value":"Class Field Mitigations","depth":3},{"value":"Function Truthy Checks","depth":3},{"value":"Local and Imported Type Declarations Now Conflict","depth":3},{"value":"3.7 API Changes","depth":3},{"value":"TypeScript 3.6","depth":2},{"value":"Stricter Generators","depth":2},{"value":"More Accurate Array Spread","depth":2},{"value":"Improved UX Around Promises","depth":2},{"value":"Better Unicode Support for Identifiers","depth":2},{"value":"import.meta Support in SystemJS","depth":2},{"value":"get and set Accessors Are Allowed in Ambient Contexts","depth":2},{"value":"Ambient Classes and Functions Can Merge","depth":2},{"value":"APIs to Support --build and --incremental","depth":2},{"value":"Semicolon-Aware Code Edits","depth":2},{"value":"Smarter Auto-Import Syntax","depth":2},{"value":"await Completions on Promises","depth":2},{"value":"New TypeScript Playground","depth":2},{"value":"TypeScript 3.5","depth":2},{"value":"Speed improvements","depth":2},{"value":"Type-checking speed-ups","depth":3},{"value":"--incremental improvements","depth":3},{"value":"The Omit helper type","depth":2},{"value":"Improved excess property checks in union types","depth":3},{"value":"The --allowUmdGlobalAccess flag","depth":2},{"value":"Smarter union type checking","depth":2},{"value":"Higher order type inference from generic constructors","depth":2},{"value":"TypeScript 3.4","depth":2},{"value":"Faster subsequent builds with the --incremental flag","depth":2},{"value":"Composite projects","depth":3},{"value":"outFile","depth":3},{"value":"Higher order type inference from generic functions","depth":2},{"value":"Improvements for ReadonlyArray and readonly tuples","depth":2},{"value":"A new syntax for ReadonlyArray","depth":3},{"value":"readonly tuples","depth":3},{"value":"readonly mapped type modifiers and readonly arrays","depth":3},{"value":"Caveats","depth":3},{"value":"const assertions","depth":2},{"value":"Caveats","depth":3},{"value":"Type-checking for globalThis","depth":2},{"value":"TypeScript 3.3","depth":2},{"value":"Improved behavior for calling union types","depth":2},{"value":"Caveats","depth":3},{"value":"Incremental file watching for composite projects in --build --watch","depth":2},{"value":"TypeScript 3.2","depth":2},{"value":"strictBindCallApply","depth":2},{"value":"Caveats","depth":3},{"value":"Generic spread expressions in object literals","depth":2},{"value":"Generic object rest variables and parameters","depth":2},{"value":"BigInt","depth":2},{"value":"Caveats","depth":3},{"value":"Non-unit types as union discriminants","depth":2},{"value":"tsconfig.json inheritance via Node.js packages","depth":2},{"value":"The new --showConfig flag","depth":2},{"value":"Object.defineProperty declarations in JavaScript","depth":2},{"value":"TypeScript 3.1","depth":2},{"value":"Mapped types on tuples and arrays","depth":2},{"value":"Properties declarations on functions","depth":2},{"value":"Version selection with typesVersions","depth":2},{"value":"Matching behavior","depth":3},{"value":"Multiple fields","depth":3},{"value":"TypeScript 3.0","depth":2},{"value":"Tuples in rest parameters and spread expressions","depth":2},{"value":"Rest parameters with tuple types","depth":3},{"value":"Spread expressions with tuple types","depth":3},{"value":"Generic rest parameters","depth":3},{"value":"Example","depth":5},{"value":"Optional elements in tuple types","depth":3},{"value":"Example","depth":5},{"value":"Rest elements in tuple types","depth":3},{"value":"Example","depth":5},{"value":"New unknown top type","depth":2},{"value":"Example","depth":5},{"value":"Support for defaultProps in JSX","depth":2},{"value":"Caveats","depth":3},{"value":"Explicit types on defaultProps","depth":4},{"value":"Changes to @types/React","depth":5},{"value":"/// <reference lib=\"...\" /> reference directives","depth":2},{"value":"Example","depth":5},{"value":"TypeScript 2.9","depth":2},{"value":"Support number and symbol named properties with keyof and mapped types","depth":2},{"value":"Example","depth":4},{"value":"Example","depth":4},{"value":"Recommendations","depth":4},{"value":"Generic type arguments in JSX elements","depth":2},{"value":"Example","depth":4},{"value":"Generic type arguments in generic tagged templates","depth":2},{"value":"Example","depth":4},{"value":"import types","depth":2},{"value":"Example","depth":4},{"value":"Relaxing declaration emit visiblity rules","depth":2},{"value":"Support for import.meta","depth":2},{"value":"Example","depth":4},{"value":"New --resolveJsonModule","depth":2},{"value":"Example","depth":4},{"value":"--pretty output by default","depth":2},{"value":"New --declarationMap","depth":2},{"value":"TypeScript 2.8","depth":2},{"value":"Conditional Types","depth":2},{"value":"Example","depth":4},{"value":"Distributive conditional types","depth":3},{"value":"Example","depth":4},{"value":"Example","depth":4},{"value":"Example","depth":4},{"value":"Type inference in conditional types","depth":3},{"value":"Predefined conditional types","depth":3},{"value":"Example","depth":4},{"value":"Improved control over mapped type modifiers","depth":2},{"value":"Example","depth":4},{"value":"Example","depth":4},{"value":"Example","depth":4},{"value":"Improved keyof with intersection types","depth":2},{"value":"Example","depth":4},{"value":"Better handling for namespace patterns in .js files","depth":2},{"value":"IIFEs as namespace declarations","depth":3},{"value":"Defaulted declarations","depth":3},{"value":"Prototype assignment","depth":3},{"value":"Nested and merged declarations","depth":3},{"value":"Per-file JSX factories","depth":2},{"value":"Example","depth":4},{"value":"Locally scoped JSX namespaces","depth":2},{"value":"New --emitDeclarationsOnly","depth":2},{"value":"TypeScript 2.7","depth":2},{"value":"Constant-named properties","depth":2},{"value":"Example","depth":4},{"value":"Example","depth":4},{"value":"unique symbol","depth":3},{"value":"Example","depth":4},{"value":"Example","depth":4},{"value":"Strict Class Initialization","depth":2},{"value":"Definite Assignment Assertions","depth":2},{"value":"Fixed Length Tuples","depth":2},{"value":"Improved type inference for object literals","depth":2},{"value":"Example","depth":4},{"value":"Improved handling of structurally identical classes and instanceof expressions","depth":2},{"value":"Example:","depth":4},{"value":"Type guards inferred from in operator","depth":2},{"value":"Example","depth":4},{"value":"Support for import d from \"cjs\" form CommonJS modules with --esModuleInterop","depth":2},{"value":"Example","depth":4},{"value":"Numeric separators","depth":2},{"value":"Example","depth":5},{"value":"Cleaner output in --watch mode","depth":2},{"value":"Prettier --pretty output","depth":2},{"value":"TypeScript 2.6","depth":2},{"value":"Strict function types","depth":2},{"value":"Example","depth":4},{"value":"Note:","depth":4},{"value":"Support for JSX Fragment Syntax","depth":2},{"value":"Cache tagged template objects in modules","depth":2},{"value":"Example","depth":4},{"value":"Localized diagnostics on the command line","depth":2},{"value":"Example","depth":4},{"value":"Suppress errors in .ts files using ’// @ts-ignore’ comments","depth":2},{"value":"Example","depth":4},{"value":"Faster tsc --watch","depth":2},{"value":"Write-only references now flagged as unused","depth":2},{"value":"Example","depth":4},{"value":"Example","depth":4},{"value":"TypeScript 2.5","depth":2},{"value":"Optional catch clause variables","depth":2},{"value":"Type assertion/cast syntax in checkJs/@ts-check mode","depth":2},{"value":"Deduplicated and redirected packages","depth":2},{"value":"The --preserveSymlinks compiler flag","depth":2},{"value":"TypeScript 2.4","depth":2},{"value":"Dynamic Import Expressions","depth":2},{"value":"String Enums","depth":2},{"value":"Improved inference for generics","depth":2},{"value":"Return types as inference targets","depth":3},{"value":"Type parameter inference from contextual types","depth":3},{"value":"Stricter checking for generic functions","depth":3},{"value":"Strict contravariance for callback parameters","depth":2},{"value":"Weak Type Detection","depth":2},{"value":"TypeScript 2.3","depth":2},{"value":"Generators and Iteration for ES5/ES3","depth":2},{"value":"Iterators","depth":4},{"value":"Generators","depth":4},{"value":"New --downlevelIteration","depth":4},{"value":"Async Iteration","depth":2},{"value":"Async iterators","depth":4},{"value":"Async Generators","depth":4},{"value":"The for-await-of Statement","depth":4},{"value":"Caveats","depth":4},{"value":"Generic parameter defaults","depth":2},{"value":"Example","depth":4},{"value":"New --strict master option","depth":2},{"value":"Enhanced --init output","depth":2},{"value":"Errors in .js files with --checkJs","depth":2},{"value":"TypeScript 2.2","depth":2},{"value":"Support for Mix-in classes","depth":2},{"value":"First some terminology:","depth":5},{"value":"Putting all of the above rules together in an example:","depth":5},{"value":"object type","depth":2},{"value":"Support for new.target","depth":2},{"value":"Example","depth":4},{"value":"Better checking for null/undefined in operands of expressions","depth":2},{"value":"Dotted property for types with string index signatures","depth":2},{"value":"Support for spread operator on JSX element children","depth":2},{"value":"Example","depth":4},{"value":"New jsx: react-native","depth":2},{"value":"TypeScript 2.1","depth":2},{"value":"keyof and Lookup Types","depth":2},{"value":"Example","depth":5},{"value":"Example","depth":5},{"value":"Mapped Types","depth":2},{"value":"Partial, Readonly, Record, and Pick","depth":2},{"value":"Object Spread and Rest","depth":2},{"value":"Downlevel Async Functions","depth":2},{"value":"Example","depth":5},{"value":"tsconfig.json","depth":5},{"value":"dramaticWelcome.ts","depth":5},{"value":"Support for external helpers library (tslib)","depth":2},{"value":"Untyped imports","depth":2},{"value":"Example","depth":5},{"value":"Support for --target ES2016, --target ES2017 and --target ESNext","depth":2},{"value":"Improved any Inference","depth":2},{"value":"Example","depth":5},{"value":"Implicit any errors","depth":2},{"value":"Example","depth":5},{"value":"Better inference for literal types","depth":2},{"value":"Example","depth":5},{"value":"Example","depth":5},{"value":"Use returned values from super calls as ‘this’","depth":2},{"value":"Example","depth":5},{"value":"Configuration inheritance","depth":2},{"value":"Example","depth":5},{"value":"New --alwaysStrict","depth":2},{"value":"TypeScript 2.0","depth":2},{"value":"Null- and undefined-aware types","depth":2},{"value":"--strictNullChecks","depth":3},{"value":"Example","depth":4},{"value":"Assigned-before-use checking","depth":3},{"value":"Example","depth":4},{"value":"Optional parameters and properties","depth":3},{"value":"Non-null and non-undefined type guards","depth":3},{"value":"Example","depth":4},{"value":"Dotted names in type guards","depth":3},{"value":"Example","depth":4},{"value":"Expression operators","depth":3},{"value":"Type widening","depth":3},{"value":"Non-null assertion operator","depth":3},{"value":"Compatibility","depth":3},{"value":"Control flow based type analysis","depth":2},{"value":"Example","depth":4},{"value":"Tagged union types","depth":2},{"value":"Example","depth":4},{"value":"The never type","depth":2},{"value":"Read-only properties and index signatures","depth":2},{"value":"Example","depth":4},{"value":"Specifying the type of this for functions","depth":2},{"value":"this parameters in callbacks","depth":3},{"value":"Example","depth":4},{"value":"--noImplicitThis","depth":3},{"value":"Glob support in tsconfig.json","depth":2},{"value":"Example","depth":4},{"value":"Module resolution enhancements: BaseUrl, Path mapping, rootDirs and tracing","depth":2},{"value":"Base URL","depth":3},{"value":"Example","depth":4},{"value":"Path mapping","depth":3},{"value":"Example","depth":4},{"value":"Virtual Directories with rootDirs","depth":3},{"value":"Example","depth":4},{"value":"Tracing module resolution","depth":3},{"value":"Shorthand ambient module declarations","depth":2},{"value":"declarations.d.ts","depth":4},{"value":"Wildcard character in module names","depth":2},{"value":"Example","depth":4},{"value":"Example","depth":4},{"value":"Support for UMD module definitions","depth":2},{"value":"math-lib.d.ts","depth":5},{"value":"Optional class properties","depth":2},{"value":"Example","depth":4},{"value":"Private and Protected Constructors","depth":2},{"value":"Example","depth":4},{"value":"Abstract properties and accessors","depth":2},{"value":"Example","depth":4},{"value":"Implicit index signatures","depth":2},{"value":"Including built-in type declarations with --lib","depth":2},{"value":"Example","depth":4},{"value":"Flag unused declarations with --noUnusedParameters and --noUnusedLocals","depth":2},{"value":"Example","depth":4},{"value":"Module identifiers allow for .js extension","depth":2},{"value":"Support ‘target : es5’ with ‘module: es6’","depth":2},{"value":"Trailing commas in function parameter and argument lists","depth":2},{"value":"Example","depth":4},{"value":"New --skipLibCheck","depth":2},{"value":"Allow duplicate identifiers across declarations","depth":2},{"value":"Example","depth":4},{"value":"New --declarationDir","depth":2},{"value":"TypeScript 1.8","depth":2},{"value":"Type parameters as constraints","depth":2},{"value":"Example","depth":5},{"value":"Control flow analysis errors","depth":2},{"value":"Unreachable code","depth":3},{"value":"Example","depth":5},{"value":"Unused labels","depth":3},{"value":"Example","depth":5},{"value":"Implicit returns","depth":3},{"value":"Example","depth":5},{"value":"Case clause fall-throughs","depth":3},{"value":"Example","depth":5},{"value":"Stateless Function Components in React","depth":2},{"value":"Simplified props type management in React","depth":2},{"value":"Augmenting global/module scope from modules","depth":2},{"value":"Example","depth":5},{"value":"Example","depth":5},{"value":"String literal types","depth":2},{"value":"Improved union/intersection type inference","depth":2},{"value":"Example","depth":5},{"value":"Concatenate AMD and System modules with --outFile","depth":2},{"value":"Example","depth":5},{"value":"Support for default import interop with SystemJS","depth":2},{"value":"Allow captured let/const in loops","depth":2},{"value":"Example","depth":5},{"value":"Improved checking for for..in statements","depth":2},{"value":"Example","depth":5},{"value":"Modules are now emitted with a \"use strict\"; prologue","depth":2},{"value":"Including .js files with --allowJs","depth":2},{"value":"Custom JSX factories using --reactNamespace","depth":2},{"value":"Example","depth":5},{"value":"this-based type guards","depth":2},{"value":"Example","depth":5},{"value":"Official TypeScript NuGet package","depth":2},{"value":"Prettier error messages from tsc","depth":2},{"value":"Colorization of JSX code in VS 2015","depth":2},{"value":"The --project (-p) flag can now take any file path","depth":2},{"value":"Allow comments in tsconfig.json","depth":2},{"value":"Support output to IPC-driven files","depth":2},{"value":"Improved support for tsconfig.json in Visual Studio 2015","depth":2},{"value":"A couple of limitations:","depth":3},{"value":"TypeScript 1.7","depth":2},{"value":"async/await support in ES6 targets (Node v4+)","depth":2},{"value":"Example","depth":5},{"value":"Support for --target ES6 with --module","depth":2},{"value":"Example","depth":5},{"value":"this-typing","depth":2},{"value":"ES7 exponentiation operator","depth":2},{"value":"Example","depth":5},{"value":"Improved checking for destructuring object literal","depth":2},{"value":"Example","depth":5},{"value":"Support for decorators when targeting ES3","depth":2},{"value":"TypeScript 1.6","depth":2},{"value":"JSX support","depth":2},{"value":"New .tsx file extension and as operator","depth":4},{"value":"Using React","depth":4},{"value":"Using other JSX frameworks","depth":4},{"value":"Output generation","depth":4},{"value":"Intersection types","depth":2},{"value":"Example","depth":5},{"value":"Local type declarations","depth":2},{"value":"Class expressions","depth":2},{"value":"Extending expressions","depth":2},{"value":"abstract classes and methods","depth":2},{"value":"Examples","depth":5},{"value":"Generic type aliases","depth":2},{"value":"Stricter object literal assignment checks","depth":2},{"value":"Examples","depth":5},{"value":"ES6 generators","depth":2},{"value":"Experimental support for async functions","depth":2},{"value":"Example","depth":5},{"value":"Nightly builds","depth":2},{"value":"Adjustments in module resolution logic","depth":2},{"value":"Merging ambient class and interface declaration","depth":2},{"value":"User-defined type guard functions","depth":2},{"value":"Examples","depth":5},{"value":"exclude property support in tsconfig.json","depth":2},{"value":"--init command line option","depth":2},{"value":"TypeScript 1.5","depth":2},{"value":"ES6 Modules","depth":2},{"value":"Export Declarations","depth":4},{"value":"Re-exporting","depth":4},{"value":"Default Export","depth":4},{"value":"Bare Import","depth":4},{"value":"Destructuring in declarations and assignments","depth":2},{"value":"Declarations","depth":4},{"value":"Assignments","depth":4},{"value":"namespace keyword","depth":2},{"value":"let and const support","depth":2},{"value":"Const","depth":4},{"value":"Block scoped","depth":4},{"value":"for..of support","depth":2},{"value":"Example","depth":5},{"value":"Decorators","depth":2},{"value":"Example","depth":5},{"value":"Computed properties","depth":2},{"value":"Support for UMD and System module output","depth":2},{"value":"Unicode codepoint escapes in strings","depth":2},{"value":"Tagged template strings in ES3/ES5","depth":2},{"value":"AMD-dependency optional names","depth":2},{"value":"Project support through tsconfig.json","depth":2},{"value":"Example","depth":5},{"value":"--rootDir command line option","depth":2},{"value":"--noEmitHelpers command line option","depth":2},{"value":"--newLine command line option","depth":2},{"value":"--inlineSourceMap and inlineSources command line options","depth":2},{"value":"TypeScript 1.4","depth":2},{"value":"Union types","depth":2},{"value":"Overview","depth":3},{"value":"Stricter Generics","depth":3},{"value":"Better Type Inference","depth":3},{"value":"let declarations","depth":2},{"value":"const declarations","depth":2},{"value":"Template strings","depth":2},{"value":"Type Guards","depth":2},{"value":"Type Aliases","depth":2},{"value":"const enum (completely inlined enums)","depth":2},{"value":"-noEmitOnError commandline option","depth":2},{"value":"AMD Module names","depth":2},{"value":"TypeScript 1.3","depth":2},{"value":"Protected","depth":2},{"value":"Tuple types","depth":2},{"value":"TypeScript 1.1","depth":2},{"value":"Performance Improvements","depth":2},{"value":"Better Module Visibility Rules","depth":2}],"frontmatter":{"permalink":"/docs/handbook/release-notes/overview.html","title":"Overview"}}},"pageContext":{"slug":"/docs/handbook/release-notes/overview.html","previous":null,"isOldHandbook":true}}}