{"componentChunkName":"component---src-templates-handbook-tsx","path":"/docs/handbook/release-notes/typescript-2-2.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":"cbaa161c-43fc-5cbf-9d8a-7dae6e715dd4","excerpt":"Support for Mix-in classes TypeScript 2.2 adds support for the ECMAScript 2015 mixin class pattern (see MDN Mixin description and “Real” Mixins with JavaScript…","html":"<h2 id=\"support-for-mix-in-classes\" style=\"position:relative;\"><a href=\"#support-for-mix-in-classes\" aria-label=\"support for mix in classes permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for Mix-in classes</h2>\n<p>TypeScript 2.2 adds support for the ECMAScript 2015 mixin class pattern (see <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#Mix-ins\">MDN Mixin description</a> and <a href=\"http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/\">“Real” Mixins with JavaScript Classes</a> for more details) as well as rules for combining mixin construct signatures with regular construct signatures in intersection types.</p>\n<h5 id=\"first-some-terminology\" style=\"position:relative;\"><a href=\"#first-some-terminology\" aria-label=\"first some terminology permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>First some terminology</h5>\n<p>A <strong>mixin constructor type</strong> refers to a type that has a single construct signature with a single rest argument of type <code>any[]</code> and an object-like return type. For example, given an object-like type <code>X</code>, <code>new (...args: any[]) => X</code> is a mixin constructor type with an instance type <code>X</code>.</p>\n<p>A <strong>mixin class</strong> is a class declaration or expression that <code>extends</code> an expression of a type parameter type. The following rules apply to mixin class declarations:</p>\n<ul>\n<li>The type parameter type of the <code>extends</code> expression must be constrained to a mixin constructor type.</li>\n<li>The constructor of a mixin class (if any) must have a single rest parameter of type <code>any[]</code> and must use the spread operator to pass those parameters as arguments in a <code>super(...args)</code> call.</li>\n</ul>\n<p>Given an expression <code>Base</code> of a parametric type <code>T</code> with a constraint <code>X</code>, a mixin class <code>class C extends Base {...}</code> is processed as if <code>Base</code> had type <code>X</code> and the resulting type is the intersection <code>typeof C &#x26; T</code>.\nIn other words, a mixin class is represented as an intersection between the mixin class constructor type and the parametric base class constructor type.</p>\n<p>When obtaining the construct signatures of an intersection type that contains mixin constructor types, the mixin construct signatures are discarded and their instance types are mixed into the return types of the other construct signatures in the intersection type.\nFor example, the intersection type <code>{ new(...args: any[]) => A } &#x26; { new(s: string) => B }</code> has a single construct signature <code>new(s: string) => A &#x26; B</code>.</p>\n<h5 id=\"putting-all-of-the-above-rules-together-in-an-example\" style=\"position:relative;\"><a href=\"#putting-all-of-the-above-rules-together-in-an-example\" aria-label=\"putting all of the above rules together in an example permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Putting all of the above rules together in an example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Point {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(</span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> x: number, </span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> y: number) {}</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Person {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(</span><span style=\"color: #0000FF\">public</span><span style=\"color: #000000\"> name: string) {}</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> Constructor&lt;T&gt; = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\">(...args: any[]) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> T;</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> Tagged&lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Constructor&lt;{}&gt;&gt;(Base: T) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Base {</span>\n<span style=\"color: #000000\">        _tag: string;</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(...args: any[]) {</span>\n<span style=\"color: #000000\">            </span><span style=\"color: #0000FF\">super</span><span style=\"color: #000000\">(...args);</span>\n<span style=\"color: #000000\">            </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">._tag = </span><span style=\"color: #A31515\">\"\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">        }</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> TaggedPoint = Tagged(Point);</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> point = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> TaggedPoint(</span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">20</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">point._tag = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Customer </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Tagged(Person) {</span>\n<span style=\"color: #000000\">    accountBalance: number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> customer = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Customer(</span><span style=\"color: #A31515\">\"Joe\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">customer._tag = </span><span style=\"color: #A31515\">\"test\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">customer.accountBalance = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>Mixin classes can constrain the types of classes they can mix into by specifying a construct signature return type in the constraint for the type parameter.\nFor example, the following <code>WithLocation</code> function implements a subclass factory that adds a <code>getLocation</code> method to any class that satisfies the <code>Point</code> interface (i.e. that has <code>x</code> and <code>y</code> properties of type <code>number</code>).</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Point {</span>\n<span style=\"color: #000000\">    x: number;</span>\n<span style=\"color: #000000\">    y: number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> WithLocation = &lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Constructor&lt;Point&gt;&gt;(Base: T) </span><span style=\"color: #0000FF\">=&gt;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Base {</span>\n<span style=\"color: #000000\">        getLocation(): [number, number] {</span>\n<span style=\"color: #000000\">            </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> [</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.x, </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.y];</span>\n<span style=\"color: #000000\">        }</span>\n<span style=\"color: #000000\">    }</span></code></div></pre>\n<h2 id=\"object-type\" style=\"position:relative;\"><a href=\"#object-type\" aria-label=\"object type permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>object</code> type</h2>\n<p>TypeScript did not have a type that represents the non-primitive type, i.e. any thing that is not <code>number</code>, <code>string</code>, <code>boolean</code>, <code>symbol</code>, <code>null</code>, or <code>undefined</code>. Enter the new <code>object</code> type.</p>\n<p>With <code>object</code> type, APIs like <code>Object.create</code> can be better represented. For example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> create(o: object | null): void;</span>\n\n<span style=\"color: #000000\">create({ prop: </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\"> }); </span><span style=\"color: #008000\">// OK</span>\n<span style=\"color: #000000\">create(</span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// OK</span>\n\n<span style=\"color: #000000\">create(</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">create(</span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">create(</span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">create(</span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// Error</span></code></div></pre>\n<h2 id=\"support-for-newtarget\" style=\"position:relative;\"><a href=\"#support-for-newtarget\" aria-label=\"support for newtarget permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for <code>new.target</code></h2>\n<p>The <code>new.target</code> meta-property is new syntax introduced in ES2015.\nWhen an instance of a constructor is created via <code>new</code>, the value of <code>new.target</code> is set to be a reference to the constructor function initially used to allocate the instance.\nIf a function is called rather than constructed via <code>new</code>, <code>new.target</code> is set to <code>undefined</code>.</p>\n<p><code>new.target</code> comes in handy when <code>Object.setPrototypeOf</code> or <code>__proto__</code> needs to be set in a class constructor. One such use case is inheriting from <code>Error</code> in NodeJS v4 and higher.</p>\n<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\">class</span><span style=\"color: #000000\"> CustomError </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Error {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(message?: string) {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">super</span><span style=\"color: #000000\">(message); </span><span style=\"color: #008000\">// 'Error' breaks prototype chain here</span>\n<span style=\"color: #000000\">        Object.setPrototypeOf(</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\">.target.prototype); </span><span style=\"color: #008000\">// restore prototype chain</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>This results in the generated JS</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> CustomError = (</span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> (_super) {</span>\n<span style=\"color: #000000\">  __extends(CustomError, _super);</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> CustomError() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> _newTarget = </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.constructor;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> _this = _super.apply(</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">arguments</span><span style=\"color: #000000\">);  </span><span style=\"color: #008000\">// 'Error' breaks prototype chain here</span>\n<span style=\"color: #000000\">    _this.__proto__ = _newTarget.prototype; </span><span style=\"color: #008000\">// restore prototype chain</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> _this;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> CustomError;</span>\n<span style=\"color: #000000\">})(Error);</span></code></div></pre>\n<p><code>new.target</code> also comes in handy for writing constructable functions, for example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\">.target) { </span><span style=\"color: #008000\">/* called via 'new' */</span><span style=\"color: #000000\"> }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Which translates to:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> _newTarget = </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\"> && </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">instanceof</span><span style=\"color: #000000\"> f ? </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.constructor : </span><span style=\"color: #0000FF\">void</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (_newTarget) { </span><span style=\"color: #008000\">/* called via 'new' */</span><span style=\"color: #000000\"> }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"better-checking-for-nullundefined-in-operands-of-expressions\" style=\"position:relative;\"><a href=\"#better-checking-for-nullundefined-in-operands-of-expressions\" aria-label=\"better checking for nullundefined in operands of expressions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Better checking for <code>null</code>/<code>undefined</code> in operands of expressions</h2>\n<p>TypeScript 2.2 improves checking of nullable operands in expressions. Specifically, these are now flagged as errors:</p>\n<ul>\n<li>If either operand of a <code>+</code> operator is nullable, and neither operand is of type <code>any</code> or <code>string</code>.</li>\n<li>If either operand of a <code>-</code>, <code>*</code>, <code>**</code>, <code>/</code>, <code>%</code>, <code>&#x3C;&#x3C;</code>, <code>>></code>, <code>>>></code>, <code>&#x26;</code>, <code>|</code>, or <code>^</code> operator is nullable.</li>\n<li>If either operand of a <code>&#x3C;</code>, <code>></code>, <code>&#x3C;=</code>, <code>>=</code>, or <code>in</code> operator is nullable.</li>\n<li>If the right operand of an <code>instanceof</code> operator is nullable.</li>\n<li>If the operand of a <code>+</code>, <code>-</code>, <code>~</code>, <code>++</code>, or <code>--</code> unary operator is nullable.</li>\n</ul>\n<p>An operand is considered nullable if the type of the operand is <code>null</code> or <code>undefined</code> or a union type that includes <code>null</code> or <code>undefined</code>.\nNote that the union type case only only occurs in <code>--strictNullChecks</code> mode because <code>null</code> and <code>undefined</code> disappear from unions in classic type checking mode.</p>\n<h2 id=\"dotted-property-for-types-with-string-index-signatures\" style=\"position:relative;\"><a href=\"#dotted-property-for-types-with-string-index-signatures\" aria-label=\"dotted property for types with string index signatures permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Dotted property for types with string index signatures</h2>\n<p>Types with a string index signature can be indexed using the <code>[]</code> notation, but were not allowed to use the <code>.</code>.\nStarting with TypeScript 2.2 using either should be allowed.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> StringMap&lt;T&gt; {</span>\n<span style=\"color: #000000\">    [x: string]: T;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> map: StringMap&lt;number&gt;;</span>\n\n<span style=\"color: #000000\">map[</span><span style=\"color: #A31515\">\"prop1\"</span><span style=\"color: #000000\">] = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">map.prop2 = </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>This only apply to types with an <em>explicit</em> string index signature.\nIt is still an error to access unknown properties on a type using <code>.</code> notation.</p>\n<h2 id=\"support-for-spread-operator-on-jsx-element-children\" style=\"position:relative;\"><a href=\"#support-for-spread-operator-on-jsx-element-children\" aria-label=\"support for spread operator on jsx element children permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for spread operator on JSX element children</h2>\n<p>TypeScript 2.2 adds support for using spread on a JSX element children.\nPlease see <a href=\"https://github.com/facebook/jsx/issues/57\">facebook/jsx#57</a> for more details.</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\">function</span><span style=\"color: #000000\"> Todo(prop: { key: number, todo: string }) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> &lt;div&gt;{prop.key.toString() + prop.todo}&lt;/div&gt;;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> TodoList({ todos }: TodoListProps) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> &lt;div&gt;</span>\n<span style=\"color: #000000\">        {...todos.map(todo </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> &lt;Todo key={todo.id} todo={todo.todo} /&gt;)}</span>\n<span style=\"color: #000000\">    &lt;/div&gt;;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: TodoListProps;</span>\n\n<span style=\"color: #000000\">&lt;TodoList {...x} /&gt;</span></code></div></pre>\n<h2 id=\"new-jsx-react-native\" style=\"position:relative;\"><a href=\"#new-jsx-react-native\" aria-label=\"new jsx react native permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New <code>jsx: react-native</code></h2>\n<p>React-native build pipeline expects all files to have a <code>.js</code> extensions even if the file contains JSX syntax.\nThe new <code>--jsx</code> value <code>react-native</code> will persevere the JSX syntax in the output file, but give it a <code>.js</code> extension.</p>","headings":[{"value":"Support for Mix-in classes","depth":2},{"value":"First some terminology","depth":5},{"value":"Putting all of the above rules together in an example","depth":5},{"value":"object type","depth":2},{"value":"Support for new.target","depth":2},{"value":"Example","depth":5},{"value":"Better checking for null/undefined in operands of expressions","depth":2},{"value":"Dotted property for types with string index signatures","depth":2},{"value":"Support for spread operator on JSX element children","depth":2},{"value":"Example","depth":5},{"value":"New jsx: react-native","depth":2}],"frontmatter":{"permalink":"/docs/handbook/release-notes/typescript-2-2.html","title":"TypeScript 2.2"}}},"pageContext":{"slug":"/docs/handbook/release-notes/typescript-2-2.html","isOldHandbook":true}}}