{"componentChunkName":"component---src-templates-handbook-tsx","path":"/docs/handbook/release-notes/typescript-1-6.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":"d64a6ec1-bb2a-5e4c-a796-ae2ac86bbbd7","excerpt":"JSX support JSX is an embeddable XML-like syntax.\nIt is meant to be transformed into valid JavaScript, but the semantics of that transformation are…","html":"<h2 id=\"jsx-support\" style=\"position:relative;\"><a href=\"#jsx-support\" aria-label=\"jsx support permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>JSX support</h2>\n<p>JSX is an embeddable XML-like syntax.\nIt is meant to be transformed into valid JavaScript, but the semantics of that transformation are implementation-specific.\nJSX came to popularity with the React library but has since seen other applications.\nTypeScript 1.6 supports embedding, type checking, and optionally compiling JSX directly into JavaScript.</p>\n<h4 id=\"new-tsx-file-extension-and-as-operator\" style=\"position:relative;\"><a href=\"#new-tsx-file-extension-and-as-operator\" aria-label=\"new tsx file extension and as operator permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New <code>.tsx</code> file extension and <code>as</code> operator</h4>\n<p>TypeScript 1.6 introduces a new <code>.tsx</code> file extension.\nThis extension does two things: it enables JSX inside of TypeScript files, and it makes the new <code>as</code> operator the default way to cast (removing any ambiguity between JSX expressions and the TypeScript prefix cast operator).\nFor example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x = &lt;any&gt; foo;</span>\n<span style=\"color: #008000\">// is equivalent to:</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x = foo </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> any;</span></code></div></pre>\n<h4 id=\"using-react\" style=\"position:relative;\"><a href=\"#using-react\" aria-label=\"using react permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Using React</h4>\n<p>To use JSX-support with React you should use the <a href=\"https://github.com/borisyankov/DefinitelyTyped/tree/master/react\">React typings</a>. These typings define the <code>JSX</code> namespace so that TypeScript can correctly check JSX expressions for React. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">/// </span><span style=\"color: #800000\">&lt;reference</span><span style=\"color: #008000\"> </span><span style=\"color: #DC0000\">path</span><span style=\"color: #000000\">=</span><span style=\"color: #A31515\">\"react.d.ts\"</span><span style=\"color: #008000\"> </span><span style=\"color: #800000\">/&gt;</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Props {</span>\n<span style=\"color: #000000\">  name: string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> MyComponent </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> React.Component&lt;Props, {}&gt; {</span>\n<span style=\"color: #000000\">  render() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> &lt;span&gt;{</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.props.foo}&lt;/span&gt;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #000000\">&lt;MyComponent name=</span><span style=\"color: #A31515\">\"bar\"</span><span style=\"color: #000000\"> /&gt;; </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #000000\">&lt;MyComponent name={0} /&gt;; </span><span style=\"color: #008000\">// error, `name` is not a number</span></code></div></pre>\n<h4 id=\"using-other-jsx-framworks\" style=\"position:relative;\"><a href=\"#using-other-jsx-framworks\" aria-label=\"using other jsx framworks permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Using other JSX framworks</h4>\n<p>JSX element names and properties are validated against the <code>JSX</code> namespace.\nPlease see the [[JSX]] wiki page for defining the <code>JSX</code> namespace for your framework.</p>\n<h4 id=\"output-generation\" style=\"position:relative;\"><a href=\"#output-generation\" aria-label=\"output generation permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Output generation</h4>\n<p>TypeScript ships with two JSX modes: <code>preserve</code> and <code>react</code>.</p>\n<ul>\n<li>The <code>preserve</code> mode will keep JSX expressions as part of the output to be further consumed by another transform step. <em>Additionally the output will have a <code>.jsx</code> file extension.</em></li>\n<li>The <code>react</code> mode will emit <code>React.createElement</code>, does not need to go through a JSX transformation before use, and the output will have a <code>.js</code> file extension.</li>\n</ul>\n<p>See the [[JSX]] wiki page for more information on using JSX in TypeScript.</p>\n<h2 id=\"intersection-types\" style=\"position:relative;\"><a href=\"#intersection-types\" aria-label=\"intersection types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Intersection types</h2>\n<p>TypeScript 1.6 introduces intersection types, the logical complement of union types.\nA union type <code>A | B</code> represents an entity that is either of type <code>A</code> or type <code>B</code>, whereas an intersection type <code>A &#x26; B</code> represents an entity that is both of type <code>A</code> <em>and</em> type <code>B</code>.</p>\n<h5 id=\"example\" 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\"> extend&lt;T, U&gt;(first: T, second: U): T & U {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> result = &lt;T & U&gt; {};</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> id </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> first) {</span>\n<span style=\"color: #000000\">        result[id] = first[id];</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> id </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> second) {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (!result.hasOwnProperty(id)) {</span>\n<span style=\"color: #000000\">            result[id] = second[id];</span>\n<span style=\"color: #000000\">        }</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> result;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x = extend({ a: </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\"> }, { b: </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\"> });</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> s = x.a;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> n = x.b;</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> LinkedList&lt;T&gt; = T & { next: LinkedList&lt;T&gt; };</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Person {</span>\n<span style=\"color: #000000\">    name: string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> people: LinkedList&lt;Person&gt;;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> s = people.name;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> s = people.next.name;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> s = people.next.next.name;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> s = people.next.next.next.name;</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> A { a: string }</span>\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> B { b: string }</span>\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> C { c: string }</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> abc: A & B & C;</span>\n<span style=\"color: #000000\">abc.a = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">abc.b = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">abc.c = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>See <a href=\"https://github.com/Microsoft/TypeScript/issues/1256\">issue #1256</a> for more information.</p>\n<h2 id=\"local-type-declarations\" style=\"position:relative;\"><a href=\"#local-type-declarations\" aria-label=\"local type declarations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Local type declarations</h2>\n<p>Local class, interface, enum, and type alias declarations can now appear inside function declarations. Local types are block scoped, similar to variables declared with <code>let</code> and <code>const</code>. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> T { x: number }</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v: T;</span>\n<span style=\"color: #000000\">        v.x = </span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> T { x: string }</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v: T;</span>\n<span style=\"color: #000000\">        v.x = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>The inferred return type of a function may be a type declared locally within the function. It is not possible for callers of the function to reference such a local type, but it can of course be matched structurally. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Point {</span>\n<span style=\"color: #000000\">    x: number;</span>\n<span style=\"color: #000000\">    y: number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> getPointFactory(x: number, y: number) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> P {</span>\n<span style=\"color: #000000\">        x = x;</span>\n<span style=\"color: #000000\">        y = y;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> P;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> PointZero = getPointFactory(</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> PointOne = getPointFactory(</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> p1 = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> PointZero();</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> p2 = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> PointZero();</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> p3 = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> PointOne();</span></code></div></pre>\n<p>Local types may reference enclosing type parameters and local class and interfaces may themselves be generic. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f3() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f&lt;X, Y&gt;(x: X, y: Y) {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">            </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> x = x;</span>\n<span style=\"color: #000000\">            </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> y = y;</span>\n<span style=\"color: #000000\">        }</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> C;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> C = f(</span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> C();</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = v.x;  </span><span style=\"color: #008000\">// number</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> y = v.y;  </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"class-expressions\" style=\"position:relative;\"><a href=\"#class-expressions\" aria-label=\"class expressions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Class expressions</h2>\n<p>TypeScript 1.6 adds support for ES6 class expressions. In a class expression, the class name is optional and, if specified, is only in scope in the class expression itself. This is similar to the optional name of a function expression. It is not possible to refer to the class instance type of a class expression outside the class expression, but the type can of course be matched structurally. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> Point = </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(</span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> x: number, </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> y: number) { }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> length() {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> Math.sqrt(</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.x * </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.x + </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.y * </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.y);</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">};</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> p = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Point(</span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">4</span><span style=\"color: #000000\">);  </span><span style=\"color: #008000\">// p has anonymous class type</span>\n<span style=\"color: #000000\">console.log(p.length());</span></code></div></pre>\n<h2 id=\"extending-expressions\" style=\"position:relative;\"><a href=\"#extending-expressions\" aria-label=\"extending expressions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Extending expressions</h2>\n<p>TypeScript 1.6 adds support for classes extending arbitrary expression that computes a constructor function. This means that built-in types can now be extended in class declarations.</p>\n<p>The <code>extends</code> clause of a class previously required a type reference to be specified. It now accepts an expression optionally followed by a type argument list. The type of the expression must be a constructor function type with at least one construct signature that has the same number of type parameters as the number of type arguments specified in the <code>extends</code> clause. The return type of the matching construct signature(s) is the base type from which the class instance type inherits. Effectively, this allows both real classes and “class-like” expressions to be specified in the <code>extends</code> clause.</p>\n<p>Some examples:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Extend built-in types</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> MyArray </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Array&lt;number&gt; { }</span>\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> MyError </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Error { }</span>\n\n<span style=\"color: #008000\">// Extend computed base class</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> ThingA {</span>\n<span style=\"color: #000000\">    getGreeting() { </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"Hello from A\"</span><span style=\"color: #000000\">; }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> ThingB {</span>\n<span style=\"color: #000000\">    getGreeting() { </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"Hello from B\"</span><span style=\"color: #000000\">; }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Greeter {</span>\n<span style=\"color: #000000\">    getGreeting(): string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> GreeterConstructor {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> (): Greeter;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> getGreeterBase(): GreeterConstructor {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> Math.random() &gt;= </span><span style=\"color: #09835A\">0.5</span><span style=\"color: #000000\"> ? ThingA : ThingB;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Test </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> getGreeterBase() {</span>\n<span style=\"color: #000000\">    sayHello() {</span>\n<span style=\"color: #000000\">        console.log(</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.getGreeting());</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"abstract-classes-and-methods\" style=\"position:relative;\"><a href=\"#abstract-classes-and-methods\" aria-label=\"abstract classes and methods permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>abstract</code> classes and methods</h2>\n<p>TypeScript 1.6 adds support for <code>abstract</code> keyword for classes and their methods. An abstract class is allowed to have methods with no implementation, and cannot be constructed.</p>\n<h5 id=\"examples\" style=\"position:relative;\"><a href=\"#examples\" aria-label=\"examples permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Examples</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">abstract</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Base {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">abstract</span><span style=\"color: #000000\"> getThing(): string;</span>\n<span style=\"color: #000000\">    getOtherThing() { </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'hello'</span><span style=\"color: #000000\">; }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Base(); </span><span style=\"color: #008000\">// Error, 'Base' is abstract</span>\n\n<span style=\"color: #008000\">// Error, must either be 'abstract' or implement concrete 'getThing'</span>\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Derived1 </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Base { }</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Derived2 </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Base {</span>\n<span style=\"color: #000000\">    getThing() { </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'hello'</span><span style=\"color: #000000\">; }</span>\n<span style=\"color: #000000\">    foo() {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">super</span><span style=\"color: #000000\">.getThing();</span><span style=\"color: #008000\">// Error: cannot invoke abstract members through 'super'</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Derived2(); </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> y: Base = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Derived2(); </span><span style=\"color: #008000\">// Also OK</span>\n<span style=\"color: #000000\">y.getThing(); </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #000000\">y.getOtherThing(); </span><span style=\"color: #008000\">// OK</span></code></div></pre>\n<h2 id=\"generic-type-aliases\" style=\"position:relative;\"><a href=\"#generic-type-aliases\" aria-label=\"generic type aliases permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Generic type aliases</h2>\n<p>With TypeScript 1.6, type aliases can be generic. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Lazy&lt;T&gt; = T | (() </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> T);</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> s: Lazy&lt;string&gt;;</span>\n<span style=\"color: #000000\">s = </span><span style=\"color: #A31515\">\"eager\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">s = () </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"lazy\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Tuple&lt;A, B&gt; {</span>\n<span style=\"color: #000000\">    a: A;</span>\n<span style=\"color: #000000\">    b: B;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Pair&lt;T&gt; = Tuple&lt;T, T&gt;;</span></code></div></pre>\n<h2 id=\"stricter-object-literal-assignment-checks\" style=\"position:relative;\"><a href=\"#stricter-object-literal-assignment-checks\" aria-label=\"stricter object literal assignment checks permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Stricter object literal assignment checks</h2>\n<p>TypeScript 1.6 enforces stricter object literal assignment checks for the purpose of catching excess or misspelled properties. Specifically, when a fresh object literal is assigned to a variable or passed as an argument for a non-empty target type, it is an error for the object literal to specify properties that don’t exist in the target type.</p>\n<h5 id=\"examples-1\" style=\"position:relative;\"><a href=\"#examples-1\" aria-label=\"examples 1 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Examples</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x: { foo: number };</span>\n<span style=\"color: #000000\">x = { foo: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, baz: </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\"> };  </span><span style=\"color: #008000\">// Error, excess property `baz`</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> y: { foo: number, bar?: number };</span>\n<span style=\"color: #000000\">y = { foo: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, baz: </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\"> };  </span><span style=\"color: #008000\">// Error, excess or misspelled property `baz`</span></code></div></pre>\n<p>A type can include an index signature to explicitly indicate that excess properties are permitted:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x: { foo: number, [x: string]: any };</span>\n<span style=\"color: #000000\">x = { foo: </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, baz: </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\"> };  </span><span style=\"color: #008000\">// Ok, `baz` matched by index signature</span></code></div></pre>\n<h2 id=\"es6-generators\" style=\"position:relative;\"><a href=\"#es6-generators\" aria-label=\"es6 generators permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>ES6 generators</h2>\n<p>TypeScript 1.6 adds support for generators when targeting ES6.</p>\n<p>A generator function can have a return type annotation, just like a function. The annotation represents the type of the generator returned by the function. Here is an example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">*</span><span style=\"color: #000000\">g(): Iterable&lt;string&gt; {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> i = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">; i &lt; </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">; i++) {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">yield</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// string is assignable to string</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">yield</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">*</span><span style=\"color: #000000\"> otherStringGenerator(); </span><span style=\"color: #008000\">// otherStringGenerator must be iterable and element type assignable to string</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>A generator function with no type annotation can have the type annotation inferred.\nSo in the following case, the type will be inferred from the yield statements:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">*</span><span style=\"color: #000000\">g() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> i = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">; i &lt; </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">; i++) {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">yield</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// infer string</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">yield</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">*</span><span style=\"color: #000000\"> otherStringGenerator(); </span><span style=\"color: #008000\">// infer element type of otherStringGenerator</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"experimental-support-for-async-functions\" style=\"position:relative;\"><a href=\"#experimental-support-for-async-functions\" aria-label=\"experimental support for async functions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Experimental support for <code>async</code> functions</h2>\n<p>TypeScript 1.6 introduces experimental support of <code>async</code> functions when targeting ES6.\nAsync functions are expected to invoke an asynchronous operation and await its result without blocking normal execution of the program.\nThis accomplished through the use of an ES6-compatible <code>Promise</code> implementation, and transposition of the function body into a compatible form to resume execution when the awaited asynchronous operation completes.</p>\n<p>An <em>async function</em> is a function or method that has been prefixed with the <code>async</code> modifier. This modifier informs the compiler that function body transposition is required, and that the keyword <code>await</code> should be treated as a unary expression instead of an identifier.\nAn <em>Async Function</em> must provide a return type annotation that points to a compatible <code>Promise</code> type. Return type inference can only be used if there is a globally defined, compatible <code>Promise</code> type.</p>\n<h5 id=\"example-1\" style=\"position:relative;\"><a href=\"#example-1\" aria-label=\"example 1 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> p: Promise&lt;number&gt; = </span><span style=\"color: #008000\">/* ... */</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> fn(): Promise&lt;number&gt; {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> i = </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> p; </span><span style=\"color: #008000\">// suspend execution until 'p' is settled. 'i' has type \"number\"</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> + i;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> a = </span><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> (): Promise&lt;number&gt; </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> + </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> p; </span><span style=\"color: #008000\">// suspends execution.</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> a = </span><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> () </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> + </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> p; </span><span style=\"color: #008000\">// suspends execution. return type is inferred as \"Promise&lt;number&gt;\" when compiling with --target ES6</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> fe = </span><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\">(): Promise&lt;number&gt; {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> i = </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> p; </span><span style=\"color: #008000\">// suspend execution until 'p' is settled. 'i' has type \"number\"</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> + i;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> m(): Promise&lt;number&gt; {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> i = </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> p; </span><span style=\"color: #008000\">// suspend execution until 'p' is settled. 'i' has type \"number\"</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> + i;</span>\n<span style=\"color: #000000\">  }</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">get</span><span style=\"color: #000000\"> p(): Promise&lt;number&gt; {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> i = </span><span style=\"color: #0000FF\">await</span><span style=\"color: #000000\"> p; </span><span style=\"color: #008000\">// suspend execution until 'p' is settled. 'i' has type \"number\"</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> + i;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"nightly-builds\" style=\"position:relative;\"><a href=\"#nightly-builds\" aria-label=\"nightly builds permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Nightly builds</h2>\n<p>While not strictly a language change, nightly builds are now available by installing with the following command:</p>\n<pre><code class=\"language-Shell\">npm install -g typescript@next\n</code></pre>\n<h2 id=\"adjustments-in-module-resolution-logic\" style=\"position:relative;\"><a href=\"#adjustments-in-module-resolution-logic\" aria-label=\"adjustments in module resolution logic permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Adjustments in module resolution logic</h2>\n<p>Starting from release 1.6 TypeScript compiler will use different set of rules to resolve module names when targeting ‘commonjs’.\nThese <a href=\"https://github.com/Microsoft/TypeScript/issues/2338\">rules</a> attempted to model module lookup procedure used by Node.\nThis effectively mean that node modules can include information about its typings and TypeScript compiler will be able to find it.\nUser however can override module resolution rules picked by the compiler by using <code>--moduleResolution</code> command line option. Possible values are:</p>\n<ul>\n<li>‘classic’ - module resolution rules used by pre 1.6 TypeScript compiler</li>\n<li>‘node’ - node-like module resolution</li>\n</ul>\n<h2 id=\"merging-ambient-class-and-interface-declaration\" style=\"position:relative;\"><a href=\"#merging-ambient-class-and-interface-declaration\" aria-label=\"merging ambient class and interface declaration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Merging ambient class and interface declaration</h2>\n<p>The instance side of an ambient class declaration can be extended using an interface declaration The class constructor object is unmodified.\nFor example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Foo {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> x : number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Foo {</span>\n<span style=\"color: #000000\">    y : string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> bar(foo : Foo)  {</span>\n<span style=\"color: #000000\">    foo.x = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// OK, declared in the class Foo</span>\n<span style=\"color: #000000\">    foo.y = </span><span style=\"color: #A31515\">\"1\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// OK, declared in the interface Foo</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"user-defined-type-guard-functions\" style=\"position:relative;\"><a href=\"#user-defined-type-guard-functions\" aria-label=\"user defined type guard functions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>User-defined type guard functions</h2>\n<p>TypeScript 1.6 adds a new way to narrow a variable type inside an <code>if</code> block, in addition to <code>typeof</code> and <code>instanceof</code>.\nA user-defined type guard functions is one with a return type annotation of the form <code>x is T</code>, where <code>x</code> is a declared parameter in the signature, and <code>T</code> is any type.\nWhen a user-defined type guard function is invoked on a variable in an <code>if</code> block, the type of the variable will be narrowed to <code>T</code>.</p>\n<h5 id=\"examples-2\" style=\"position:relative;\"><a href=\"#examples-2\" aria-label=\"examples 2 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Examples</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> isCat(a: any): a </span><span style=\"color: #0000FF\">is</span><span style=\"color: #000000\"> Cat {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> a.name === </span><span style=\"color: #A31515\">'kitty'</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> x: Cat | Dog;</span>\n<span style=\"color: #0000FF\">if</span><span style=\"color: #000000\">(isCat(x)) {</span>\n<span style=\"color: #000000\">  x.meow(); </span><span style=\"color: #008000\">// OK, x is Cat in this block</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"exclude-property-support-in-tsconfigjson\" style=\"position:relative;\"><a href=\"#exclude-property-support-in-tsconfigjson\" aria-label=\"exclude property support in tsconfigjson permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>exclude</code> property support in tsconfig.json</h2>\n<p>A tsconfig.json file that doesn’t specify a files property (and therefore implicitly references all *.ts files in all subdirectories) can now contain an exclude property that specifies a list of files and/or directories to exclude from the compilation.\nThe exclude property must be an array of strings that each specify a file or folder name relative to the location of the tsconfig.json file.\nFor example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"compilerOptions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0451A5\">\"out\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"test.js\"</span>\n<span style=\"color: #000000\">    },</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"exclude\"</span><span style=\"color: #000000\">: [</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #A31515\">\"node_modules\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #A31515\">\"test.ts\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #A31515\">\"utils/t2.ts\"</span>\n<span style=\"color: #000000\">    ]</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>The <code>exclude</code> list does not support wilcards. It must simply be a list of files and/or directories.</p>\n<h2 id=\"--init-command-line-option\" style=\"position:relative;\"><a href=\"#--init-command-line-option\" aria-label=\"  init command line option permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>--init</code> command line option</h2>\n<p>Run <code>tsc --init</code> in a directory to create an initial <code>tsconfig.json</code> in this directory with preset defaults.\nOptionally pass command line arguments along with <code>--init</code> to be stored in your initial tsconfig.json on creation.</p>","headings":[{"value":"JSX support","depth":2},{"value":"New .tsx file extension and as operator","depth":4},{"value":"Using React","depth":4},{"value":"Using other JSX framworks","depth":4},{"value":"Output generation","depth":4},{"value":"Intersection types","depth":2},{"value":"Example","depth":5},{"value":"Local type declarations","depth":2},{"value":"Class expressions","depth":2},{"value":"Extending expressions","depth":2},{"value":"abstract classes and methods","depth":2},{"value":"Examples","depth":5},{"value":"Generic type aliases","depth":2},{"value":"Stricter object literal assignment checks","depth":2},{"value":"Examples","depth":5},{"value":"ES6 generators","depth":2},{"value":"Experimental support for async functions","depth":2},{"value":"Example","depth":5},{"value":"Nightly builds","depth":2},{"value":"Adjustments in module resolution logic","depth":2},{"value":"Merging ambient class and interface declaration","depth":2},{"value":"User-defined type guard functions","depth":2},{"value":"Examples","depth":5},{"value":"exclude property support in tsconfig.json","depth":2},{"value":"--init command line option","depth":2}],"frontmatter":{"permalink":"/docs/handbook/release-notes/typescript-1-6.html","title":"TypeScript 1.6"}}},"pageContext":{"slug":"/docs/handbook/release-notes/typescript-1-6.html","isOldHandbook":true}}}