{"componentChunkName":"component---src-templates-handbook-tsx","path":"/docs/handbook/release-notes/typescript-2-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":"665aeb67-ad0d-5db7-9d48-4eef1b1a80b1","excerpt":"Strict function types TypeScript 2.6 introduces a new strict checking flag, --strictFunctionTypes.\nThe --strictFunctionTypes switch is part of the --strict…","html":"<h2 id=\"strict-function-types\" style=\"position:relative;\"><a href=\"#strict-function-types\" aria-label=\"strict function types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Strict function types</h2>\n<p>TypeScript 2.6 introduces a new strict checking flag, <code>--strictFunctionTypes</code>.\nThe <code>--strictFunctionTypes</code> switch is part of the <code>--strict</code> family of switches, meaning that it defaults to on in <code>--strict</code> mode.\nYou can opt-out by setting <code>--strictFunctionTypes false</code> on your command line or in your tsconfig.json.</p>\n<p>Under <code>--strictFunctionTypes</code> function type parameter positions are checked <em>contravariantly</em> instead of <em>bivariantly</em>.\nFor some background on what variance means for function types check out <a href=\"https://www.stephanboyer.com/post/132/what-are-covariance-and-contravariance\">What are covariance and contravariance?</a>.</p>\n<p>The stricter checking applies to all function types, <em>except</em> those originating in method or constructor declarations.\nMethods are excluded specifically to ensure generic classes and interfaces (such as <code>Array&#x3C;T></code>) continue to mostly relate covariantly.</p>\n<p>Consider the following example in which <code>Animal</code> is the supertype of <code>Dog</code> and <code>Cat</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> f1: (x: Animal) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> f2: (x: Dog) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> f3: (x: Cat) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void;</span>\n<span style=\"color: #000000\">f1 = f2;  </span><span style=\"color: #008000\">// Error with --strictFunctionTypes</span>\n<span style=\"color: #000000\">f2 = f1;  </span><span style=\"color: #008000\">// Ok</span>\n<span style=\"color: #000000\">f2 = f3;  </span><span style=\"color: #008000\">// Error</span></code></div></pre>\n<p>The first assignment is permitted in default type checking mode, but flagged as an error in strict function types mode.\nIntuitively, the default mode permits the assignment because it is <em>possibly</em> sound, whereas strict function types mode makes it an error because it isn’t <em>provably</em> sound.\nIn either mode the third assignment is an error because it is <em>never</em> sound.</p>\n<p>Another way to describe the example is that the type <code>(x: T) => void</code> is <em>bivariant</em> (i.e. covariant <em>or</em> contravariant) for <code>T</code> in default type checking mode, but <em>contravariant</em> for <code>T</code> in strict function types mode.</p>\n<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\">interface</span><span style=\"color: #000000\"> Comparer&lt;T&gt; {</span>\n<span style=\"color: #000000\">    compare: (a: T, b: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> animalComparer: Comparer&lt;Animal&gt;;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> dogComparer: Comparer&lt;Dog&gt;;</span>\n\n<span style=\"color: #000000\">animalComparer = dogComparer;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">dogComparer = animalComparer;  </span><span style=\"color: #008000\">// Ok</span></code></div></pre>\n<p>The first assignment is now an error. Effectively, <code>T</code> is contravariant in <code>Comparer&#x3C;T></code> because it is used only in function type parameter positions.</p>\n<p>By the way, note that whereas some languages (e.g. C# and Scala) require variance annotations (<code>out</code>/<code>in</code> or <code>+</code>/<code>-</code>), variance emerges naturally from the actual use of a type parameter within a generic type due to TypeScript’s structural type system.</p>\n<h5 id=\"note\" style=\"position:relative;\"><a href=\"#note\" aria-label=\"note permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Note</h5>\n<p>Under <code>--strictFunctionTypes</code> the first assignment is still permitted if <code>compare</code> was declared as a method.\nEffectively, <code>T</code> is bivariant in <code>Comparer&#x3C;T></code> because it is used only in method parameter positions.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Comparer&lt;T&gt; {</span>\n<span style=\"color: #000000\">    compare(a: T, b: T): number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> animalComparer: Comparer&lt;Animal&gt;;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> dogComparer: Comparer&lt;Dog&gt;;</span>\n\n<span style=\"color: #000000\">animalComparer = dogComparer;  </span><span style=\"color: #008000\">// Ok because of bivariance</span>\n<span style=\"color: #000000\">dogComparer = animalComparer;  </span><span style=\"color: #008000\">// Ok</span></code></div></pre>\n<p>TypeScript 2.6 also improves type inference involving contravariant positions:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> combine&lt;T&gt;(...funcs: ((x: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void)[]): (x: T) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">for</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> f </span><span style=\"color: #0000FF\">of</span><span style=\"color: #000000\"> funcs) f(x);</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> animalFunc(x: Animal) {}</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> dogFunc(x: Dog) {}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> combined = combine(animalFunc, dogFunc);  </span><span style=\"color: #008000\">// (x: Dog) =&gt; void</span></code></div></pre>\n<p>Above, all inferences for <code>T</code> originate in contravariant positions, and we therefore infer the <em>best common subtype</em> for <code>T</code>.\nThis contrasts with inferences from covariant positions, where we infer the <em>best common supertype</em>.</p>\n<h2 id=\"cache-tagged-template-objects-in-modules\" style=\"position:relative;\"><a href=\"#cache-tagged-template-objects-in-modules\" aria-label=\"cache tagged template objects in modules permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Cache tagged template objects in modules</h2>\n<p>TypeScript 2.6 fixes the tagged string template emit to align better with the ECMAScript spec.\nAs per the <a href=\"https://tc39.github.io/ecma262/#sec-gettemplateobject\">ECMAScript spec</a>, every time a template tag is evaluated, the <em>same</em> template strings object (the same <code>TemplateStringsArray</code>) should be passed as the first argument.\nBefore TypeScript 2.6, the generated output was a completely new template object each time.\nThough the string contents are the same, this emit affects libraries that use the identity of the string for cache invalidation purposes, e.g. <a href=\"https://github.com/PolymerLabs/lit-html/issues/58\">lit-html</a>.</p>\n<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\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> id(x: TemplateStringsArray) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> templateObjectFactory() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">id`hello world`</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> result = templateObjectFactory() === templateObjectFactory(); </span><span style=\"color: #008000\">// true in TS 2.6</span></code></div></pre>\n<p>Results in the following generated code:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #A31515\">\"use strict\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> __makeTemplateObject = (</span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\"> && </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.__makeTemplateObject) || </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> (cooked, raw) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (Object.defineProperty) { Object.defineProperty(cooked, </span><span style=\"color: #A31515\">\"raw\"</span><span style=\"color: #000000\">, { value: raw }); } </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> { cooked.raw = raw; }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> cooked;</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> id(x) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> x;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> _a;</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> templateObjectFactory() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> id(_a || (_a = __makeTemplateObject([</span><span style=\"color: #A31515\">\"hello world\"</span><span style=\"color: #000000\">], [</span><span style=\"color: #A31515\">\"hello world\"</span><span style=\"color: #000000\">])));</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> result = templateObjectFactory() === templateObjectFactory();</span></code></div></pre>\n<blockquote>\n<p>Note: This change brings a new emit helper, <code>__makeTemplateObject</code>;\nif you are using <code>--importHelpers</code> with <a href=\"https://github.com/Microsoft/tslib\"><code>tslib</code></a>, an updated to version 1.8 or later.</p>\n</blockquote>\n<h2 id=\"localized-diagnostics-on-the-command-line\" style=\"position:relative;\"><a href=\"#localized-diagnostics-on-the-command-line\" aria-label=\"localized diagnostics on the command line permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Localized diagnostics on the command line</h2>\n<p>TypeScript 2.6 npm package ships with localized versions of diagnostic messages for 13 languages.\nThe localized messages are available when using <code>--locale</code> flag on the command line.</p>\n<h5 id=\"example-2\" style=\"position:relative;\"><a href=\"#example-2\" aria-label=\"example 2 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<p>Error messages in Russian:</p>\n<pre class=\"shiki\"><div class=\"language-id\">sh</div><div class='code-container'><code><span style=\"color: #000000\">c:\\ts&gt;tsc --v</span>\n<span style=\"color: #000000\">Version 2.6.0-dev.20171003</span>\n\n<span style=\"color: #000000\">c:\\ts&gt;tsc --locale ru --pretty c:\\test\\a.ts</span>\n\n<span style=\"color: #000000\">../test/a.ts(1,5): error TS2322: Тип </span><span style=\"color: #A31515\">\"\"</span><span style=\"color: #000000\">string</span><span style=\"color: #A31515\">\"\"</span><span style=\"color: #000000\"> не может быть назначен для типа </span><span style=\"color: #A31515\">\"number\"</span><span style=\"color: #000000\">.</span>\n\n<span style=\"color: #000000\">1 var x: number = </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">      ~</span></code></div></pre>\n<p>And help in Japanese:</p>\n<pre class=\"shiki\"><div class=\"language-id\">sh</div><div class='code-container'><code><span style=\"color: #000000\">PS C:\\ts&gt; tsc --v</span>\n<span style=\"color: #000000\">Version 2.6.0-dev.20171003</span>\n\n<span style=\"color: #000000\">PS C:\\ts&gt; tsc --locale ja-jp</span>\n<span style=\"color: #000000\">バージョン 2.6.0-dev.20171003</span>\n<span style=\"color: #000000\">構文: tsc [オプション] [ファイル ...]</span>\n\n<span style=\"color: #000000\">例:  tsc hello.ts</span>\n<span style=\"color: #000000\">    tsc --outFile file.js file.ts</span>\n<span style=\"color: #000000\">    tsc @args.txt</span>\n\n<span style=\"color: #000000\">オプション:</span>\n<span style=\"color: #000000\"> -h, --help                                 このメッセージを表示します。</span>\n<span style=\"color: #000000\"> --all                                      コンパイラ オプションをすべて表示します。</span>\n<span style=\"color: #000000\"> -v, --version                              コンパイラのバージョンを表示します。</span>\n<span style=\"color: #000000\"> --init                                     TypeScript プロジェクトを初期化して、tsconfig.json ファイルを作成します。</span>\n<span style=\"color: #000000\"> -p ファイルまたはディレクトリ, --project ファイルまたはディレクトリ  構成ファイルか、</span><span style=\"color: #A31515\">'tsconfig.json'</span><span style=\"color: #000000\"> を含むフォルダーにパスが指定されたプロジェクトをコ</span>\n<span style=\"color: #000000\">ンパイルします。</span>\n<span style=\"color: #000000\"> --pretty                                   色とコンテキストを使用してエラーとメッセージにスタイルを適用します (試験的)。</span>\n<span style=\"color: #000000\"> -w, --watch                                入力ファイルを監視します。</span>\n<span style=\"color: #000000\"> -t バージョン, --target バージョン                   ECMAScript のターゲット バージョンを指定します: </span><span style=\"color: #A31515\">'ES3'</span><span style=\"color: #000000\"> (既定)、</span><span style=\"color: #A31515\">'ES5'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'ES2015'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'ES2016'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'ES2017'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'ES</span>\n<span style=\"color: #A31515\">NEXT'</span><span style=\"color: #000000\">。</span>\n<span style=\"color: #000000\"> -m 種類, --module 種類                         モジュール コード生成を指定します: </span><span style=\"color: #A31515\">'none'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'commonjs'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'amd'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'system'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'umd'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'es2015'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'ESNext'</span><span style=\"color: #000000\">。</span>\n<span style=\"color: #000000\"> --lib                                      コンパイルに含めるライブラリ ファイルを指定します:</span>\n<span style=\"color: #000000\">                                              </span><span style=\"color: #A31515\">'es5'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es6'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es7'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2016'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2017'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'esnext'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'dom'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'dom.iterable'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'webworker'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'scripthost'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es201</span>\n<span style=\"color: #A31515\">5.core'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015.collection'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015.generator'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015.iterable'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015.promise'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015.proxy'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015.reflect'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015.symbol'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2015.symbol.wellkno</span>\n<span style=\"color: #A31515\">wn'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2016.array.include'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2017.object'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2017.sharedmemory'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2017.string'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'es2017.intl'</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">'esnext.asynciterable'</span>\n<span style=\"color: #000000\"> --allowJs                                  javascript ファイルのコンパイルを許可します。</span>\n<span style=\"color: #000000\"> --jsx 種類                                   JSX コード生成を指定します: </span><span style=\"color: #A31515\">'preserve'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'react-native'</span><span style=\"color: #000000\">、</span><span style=\"color: #A31515\">'react'</span><span style=\"color: #000000\">。</span>\n<span style=\"color: #000000\"> -d, --declaration                          対応する </span><span style=\"color: #A31515\">'.d.ts'</span><span style=\"color: #000000\"> ファイルを生成します。</span>\n<span style=\"color: #000000\"> --sourceMap                                対応する </span><span style=\"color: #A31515\">'.map'</span><span style=\"color: #000000\"> ファイルを生成します。</span>\n<span style=\"color: #000000\"> --outFile ファイル                             出力を連結して 1 つのファイルを生成します。</span>\n<span style=\"color: #000000\"> --outDir ディレクトリ                            ディレクトリへ出力構造をリダイレクトします。</span>\n<span style=\"color: #000000\"> --removeComments                           コメントを出力しないでください。</span>\n<span style=\"color: #000000\"> --noEmit                                   出力しないでください。</span>\n<span style=\"color: #000000\"> --strict                                   strict 型チェックのオプションをすべて有効にします。</span>\n<span style=\"color: #000000\"> --noImplicitAny                            暗黙的な </span><span style=\"color: #A31515\">'any'</span><span style=\"color: #000000\"> 型を含む式と宣言に関するエラーを発生させます。</span>\n<span style=\"color: #000000\"> --strictNullChecks                         厳格な null チェックを有効にします。</span>\n<span style=\"color: #000000\"> --noImplicitThis                           暗黙的な </span><span style=\"color: #A31515\">'any'</span><span style=\"color: #000000\"> 型を持つ </span><span style=\"color: #A31515\">'this'</span><span style=\"color: #000000\"> 式でエラーが発生します。</span>\n<span style=\"color: #000000\"> --alwaysStrict                             厳格モードで解析してソース ファイルごとに </span><span style=\"color: #A31515\">\"use strict\"</span><span style=\"color: #000000\"> を生成します。</span>\n<span style=\"color: #000000\"> --noUnusedLocals                           使用されていないローカルに関するエラーを報告します。</span>\n<span style=\"color: #000000\"> --noUnusedParameters                       使用されていないパラメーターに関するエラーを報告します。</span>\n<span style=\"color: #000000\"> --noImplicitReturns                        関数の一部のコード パスが値を返さない場合にエラーを報告します。</span>\n<span style=\"color: #000000\"> --noFallthroughCasesInSwitch               switch ステートメントに </span><span style=\"color: #0000FF\">case</span><span style=\"color: #000000\"> のフォールスルーがある場合にエラーを報告します。</span>\n<span style=\"color: #000000\"> --types                                    コンパイルに含む型宣言ファイル。</span>\n<span style=\"color: #000000\"> @&lt;ファイル&gt;</span></code></div></pre>\n<h2 id=\"suppress-errors-in-ts-files-using--ts-ignore-comments\" style=\"position:relative;\"><a href=\"#suppress-errors-in-ts-files-using--ts-ignore-comments\" aria-label=\"suppress errors in ts files using  ts ignore comments permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Suppress errors in .ts files using ’// @ts-ignore’ comments</h2>\n<p>TypeScript 2.6 support suppressing errors in .js files using <code>// @ts-ignore</code> comments placed above the offending lines.</p>\n<h5 id=\"example-3\" style=\"position:relative;\"><a href=\"#example-3\" aria-label=\"example 3 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// @ts-ignore: Unreachable code error</span>\n<span style=\"color: #000000\">    console.log(</span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>A <code>// @ts-ignore</code> comment suppresses all errors that originate on the following line.\nIt is recommended practice to have the remainder of the comment following <code>@ts-ignore</code> explain which error is being suppressed.</p>\n<p>Please note that this comment only suppresses the error reporting, and we recommend you use this comments <em>very sparingly</em>.</p>\n<h2 id=\"faster-tsc---watch\" style=\"position:relative;\"><a href=\"#faster-tsc---watch\" aria-label=\"faster tsc   watch permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Faster <code>tsc --watch</code></h2>\n<p>TypeScript 2.6 brings a faster <code>--watch</code> implementation.\nThe new version optimizes code generation and checking for code bases using ES modules.\nChanges detected in a module file will result in <em>only</em> regenerating the changed module, and files that depend on it, instead of the whole project.\nProjects with large number of files should reap the most benefit from this change.</p>\n<p>The new implementation also brings performance enhancements to watching in tsserver.\nThe watcher logic has been completely rewritten to respond faster to change events.</p>\n<h2 id=\"write-only-references-now-flagged-as-unused\" style=\"position:relative;\"><a href=\"#write-only-references-now-flagged-as-unused\" aria-label=\"write only references now flagged as unused permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Write-only references now flagged as unused</h2>\n<p>TypeScript 2.6 adds revised implementation  the <code>--noUnusedLocals</code> and <code>--noUnusedParameters</code> <a href=\"https://www.typescriptlang.org/docs/handbook/compiler-options.html\">compiler options</a>.\nDeclarations are only written to but never read from are now flagged as unused.</p>\n<h5 id=\"example-4\" style=\"position:relative;\"><a href=\"#example-4\" aria-label=\"example 4 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<p>Bellow both <code>n</code> and <code>m</code> will be marked as unused, because their values are never <em>read</em>. Previously TypeScript would only check whether their values were <em>referenced</em>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f(n: number) {</span>\n<span style=\"color: #000000\">    n = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">private</span><span style=\"color: #000000\"> m: number;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">() {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.m = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Also functions that are only called within their own bodies are considered unused.</p>\n<h5 id=\"example-5\" style=\"position:relative;\"><a href=\"#example-5\" aria-label=\"example 5 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f() {</span>\n<span style=\"color: #000000\">    f(); </span><span style=\"color: #008000\">// Error: 'f' is declared but its value is never read</span>\n<span style=\"color: #000000\">}</span></code></div></pre>","headings":[{"value":"Strict function types","depth":2},{"value":"Example","depth":5},{"value":"Note","depth":5},{"value":"Cache tagged template objects in modules","depth":2},{"value":"Example","depth":5},{"value":"Localized diagnostics on the command line","depth":2},{"value":"Example","depth":5},{"value":"Suppress errors in .ts files using ’// @ts-ignore’ comments","depth":2},{"value":"Example","depth":5},{"value":"Faster tsc --watch","depth":2},{"value":"Write-only references now flagged as unused","depth":2},{"value":"Example","depth":5},{"value":"Example","depth":5}],"frontmatter":{"permalink":"/docs/handbook/release-notes/typescript-2-6.html","title":"TypeScript 2.6"}}},"pageContext":{"slug":"/docs/handbook/release-notes/typescript-2-6.html","isOldHandbook":true}}}