{"componentChunkName":"component---src-templates-handbook-tsx","path":"/docs/handbook/release-notes/typescript-1-8.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":"f182f010-69e1-5146-849e-f5e6501403dd","excerpt":"Type parameters as constraints With TypeScript 1.8 it becomes possible for a type parameter constraint to reference type parameters from the same type parameter…","html":"<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.\nPreviously this was an error.\nThis 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\" 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\">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.\nFor instance, statements following unconditional <code>return</code>, <code>throw</code>, <code>break</code> or <code>continue</code> statements are considered unreachable.\nUse <code>--allowUnreachableCode</code> to disable unreachable code detection and reporting.</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<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>\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.\nJust like unreachable code checks, these are turned on by default;\nuse <code>--allowUnusedLabels</code> to stop reporting these errors.</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: #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><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>.\nThese can now be flagged by the compiler as implicit returns.\nThe check is turned <em>off</em> by default; use <code>--noImplicitReturns</code> to turn it on.</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: #0000FF\">function</span><span style=\"color: #000000\"> f(x) { </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-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>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=\"function-components-in-react\" style=\"position:relative;\"><a href=\"#function-components-in-react\" aria-label=\"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>Function Components in React</h2>\n<p>TypeScript now supports <a href=\"https://reactjs.org/docs/components-and-props.html#functional-and-class-components\">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-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</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-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</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><span style=\"color: #008000\">/* ... */</span><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-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</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-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</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-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</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><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> i; });</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><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> console.log(f()); });</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-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</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><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-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</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=\"./typescript-1.6.html#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 narowing 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-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</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><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\">    isDirectory(): this </span><span style=\"color: #0000FF\">is</span><span style=\"color: #000000\"> Directory { </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\">    isNetworked(): this </span><span style=\"color: #0000FF\">is</span><span style=\"color: #000000\"> (Networked & this) { </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><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><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: #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>\n<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>\n<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\">myget</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>","headings":[{"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":"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}],"frontmatter":{"permalink":"/docs/handbook/release-notes/typescript-1-8.html","title":"TypeScript 1.8"}}},"pageContext":{"slug":"/docs/handbook/release-notes/typescript-1-8.html","isOldHandbook":true}}}