{"componentChunkName":"component---src-templates-handbook-tsx","path":"/docs/handbook/release-notes/typescript-3-0.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":"8011e377-ad18-5da8-b524-4876d337bf77","excerpt":"Project References TypeScript 3.0 introduces a new concept of project references. Project references allow TypeScript projects to depend on other TypeScript…","html":"<h2 id=\"project-references\" style=\"position:relative;\"><a href=\"#project-references\" aria-label=\"project references permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Project References</h2>\n<p>TypeScript 3.0 introduces a new concept of project references. Project references allow TypeScript projects to depend on other TypeScript projects - specifically, allowing <code>tsconfig.json</code> files to reference other <code>tsconfig.json</code> files. Specifying these dependencies makes it easier to split your code into smaller projects, since it gives TypeScript (and tools around it) a way to understand build ordering and output structure.</p>\n<p>TypeScript 3.0 also introduces a new mode for tsc, the <code>--build</code> flag, that works hand-in-hand with project references to enable faster TypeScript builds.</p>\n<p>See <a href=\"../Project%20References.md\">Project References handbook page</a> for more documentation.</p>\n<h2 id=\"tuples-in-rest-parameters-and-spread-expressions\" style=\"position:relative;\"><a href=\"#tuples-in-rest-parameters-and-spread-expressions\" aria-label=\"tuples in rest parameters and spread expressions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Tuples in rest parameters and spread expressions</h2>\n<p>TypeScript 3.0 adds support to multiple new capabilities to interact with function parameter lists as tuple types.\nTypeScript 3.0 adds support for:</p>\n<ul>\n<li><a href=\"#rest-parameters-with-tuple-types\">Expansion of rest parameters with tuple types into discrete parameters.</a></li>\n<li><a href=\"#spread-expressions-with-tuple-types\">Expansion of spread expressions with tuple types into discrete arguments.</a></li>\n<li><a href=\"#generic-rest-parameters\">Generic rest parameters and corresponding inference of tuple types.</a></li>\n<li><a href=\"#optional-elements-in-tuple-types\">Optional elements in tuple types.</a></li>\n<li><a href=\"#rest-elements-in-tuple-types\">Rest elements in tuple types.</a></li>\n</ul>\n<p>With these features it becomes possible to strongly type a number of higher-order functions that transform functions and their parameter lists.</p>\n<h2 id=\"rest-parameters-with-tuple-types\" style=\"position:relative;\"><a href=\"#rest-parameters-with-tuple-types\" aria-label=\"rest parameters with tuple types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Rest parameters with tuple types</h2>\n<p>When a rest parameter has a tuple type, the tuple type is expanded into a sequence of discrete parameters.\nFor example the following two declarations are equivalent:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> foo(...args: [number, string, boolean]): void;</span></code></div></pre>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> foo(args_0: number, args_1: string, args_2: boolean): void;</span></code></div></pre>\n<h2 id=\"spread-expressions-with-tuple-types\" style=\"position:relative;\"><a href=\"#spread-expressions-with-tuple-types\" aria-label=\"spread expressions with tuple types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Spread expressions with tuple types</h2>\n<p>When a function call includes a spread expression of a tuple type as the last argument, the spread expression corresponds to a sequence of discrete arguments of the tuple element types.</p>\n<p>Thus, the following calls are equivalent:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> args: [number, string, boolean] = [</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">];</span>\n<span style=\"color: #000000\">foo(</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">foo(args[</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">], args[</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">], args[</span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">]);</span>\n<span style=\"color: #000000\">foo(...args);</span></code></div></pre>\n<h2 id=\"generic-rest-parameters\" style=\"position:relative;\"><a href=\"#generic-rest-parameters\" aria-label=\"generic rest parameters permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Generic rest parameters</h2>\n<p>A rest parameter is permitted to have a generic type that is constrained to an array type, and type inference can infer tuple types for such generic rest parameters. This enables higher-order capturing and spreading of partial parameter lists:</p>\n<h5 id=\"example\" style=\"position:relative;\"><a href=\"#example\" aria-label=\"example permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> bind&lt;T, U </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> any[], V&gt;(f: (x: T, ...args: U) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> V, x: T): (...args: U) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> V;</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f3(x: number, y: string, z: boolean): void;</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> f2 = bind(f3, </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">);  </span><span style=\"color: #008000\">// (y: string, z: boolean) =&gt; void</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> f1 = bind(f2, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">);  </span><span style=\"color: #008000\">// (z: boolean) =&gt; void</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> f0 = bind(f1, </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">);  </span><span style=\"color: #008000\">// () =&gt; void</span>\n\n<span style=\"color: #000000\">f3(</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">f2(</span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">f1(</span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">f0();</span></code></div></pre>\n<p>In the declaration of <code>f2</code> above, type inference infers types <code>number</code>, <code>[string, boolean]</code> and <code>void</code> for <code>T</code>, <code>U</code> and <code>V</code> respectively.</p>\n<p>Note that when a tuple type is inferred from a sequence of parameters and later expanded into a parameter list, as is the case for <code>U</code>, the original parameter names are used in the expansion (however, the names have no semantic meaning and are not otherwise observable).</p>\n<h2 id=\"optional-elements-in-tuple-types\" style=\"position:relative;\"><a href=\"#optional-elements-in-tuple-types\" aria-label=\"optional elements in tuple types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Optional elements in tuple types</h2>\n<p>Tuple types now permit a <code>?</code> postfix on element types to indicate that the element is optional:</p>\n<h5 id=\"example-1\" style=\"position:relative;\"><a href=\"#example-1\" aria-label=\"example 1 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> t: [number, string?, boolean?];</span>\n<span style=\"color: #000000\">t = [</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">];</span>\n<span style=\"color: #000000\">t = [</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">];</span>\n<span style=\"color: #000000\">t = [</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">];</span></code></div></pre>\n<p>In <code>--strictNullChecks</code> mode, a <code>?</code> modifier automatically includes <code>undefined</code> in the element type, similar to optional parameters.</p>\n<p>A tuple type permits an element to be omitted if it has a postfix <code>?</code> modifier on its type and all elements to the right of it also have <code>?</code> modifiers.</p>\n<p>When tuple types are inferred for rest parameters, optional parameters in the source become optional tuple elements in the inferred type.</p>\n<p>The <code>length</code> property of a tuple type with optional elements is a union of numeric literal types representing the possible lengths.\nFor example, the type of the <code>length</code> property in the tuple type <code>[number, string?, boolean?]</code> is <code>1 | 2 | 3</code>.</p>\n<h3 id=\"rest-elements-in-tuple-types\" style=\"position:relative;\"><a href=\"#rest-elements-in-tuple-types\" aria-label=\"rest elements in tuple types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Rest elements in tuple types</h3>\n<p>The last element of a tuple type can be a rest element of the form <code>...X</code>, where <code>X</code> is an array type.\nA rest element indicates that the tuple type is open-ended and may have zero or more additional elements of the array element type.\nFor example, <code>[number, ...string[]]</code> means tuples with a <code>number</code> element followed by any number of <code>string</code> elements.</p>\n<h5 id=\"example-2\" style=\"position:relative;\"><a href=\"#example-2\" aria-label=\"example 2 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> tuple&lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> any[]&gt;(...args: T): T {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> args;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> numbers: number[] = getArrayOfNumbers();</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> t1 = tuple(</span><span style=\"color: #A31515\">\"foo\"</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">);  </span><span style=\"color: #008000\">// [string, number, boolean]</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> t2 = tuple(</span><span style=\"color: #A31515\">\"bar\"</span><span style=\"color: #000000\">, ...numbers);  </span><span style=\"color: #008000\">// [string, ...number[]]</span></code></div></pre>\n<p>The type of the <code>length</code> property of a tuple type with a rest element is <code>number</code>.</p>\n<h2 id=\"new-unknown-top-type\" style=\"position:relative;\"><a href=\"#new-unknown-top-type\" aria-label=\"new unknown top type permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New <code>unknown</code> top type</h2>\n<p>TypeScript 3.0 introduces a new top type <code>unknown</code>.\n<code>unknown</code> is the type-safe counterpart of <code>any</code>.\nAnything is assignable to <code>unknown</code>, but <code>unknown</code> isn’t assignable to anything but itself and <code>any</code> without a type assertion or a control flow based narrowing.\nLikewise, no operations are permitted on an <code>unknown</code> without first asserting or narrowing to a more specific type.</p>\n<h5 id=\"example-3\" style=\"position:relative;\"><a href=\"#example-3\" aria-label=\"example 3 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// In an intersection everything absorbs unknown</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T00 = unknown & null;  </span><span style=\"color: #008000\">// null</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T01 = unknown & undefined;  </span><span style=\"color: #008000\">// undefined</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T02 = unknown & null & undefined;  </span><span style=\"color: #008000\">// null & undefined (which becomes never)</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T03 = unknown & string;  </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T04 = unknown & string[];  </span><span style=\"color: #008000\">// string[]</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T05 = unknown & unknown;  </span><span style=\"color: #008000\">// unknown</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T06 = unknown & any;  </span><span style=\"color: #008000\">// any</span>\n\n<span style=\"color: #008000\">// In a union an unknown absorbs everything</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T10 = unknown | null;  </span><span style=\"color: #008000\">// unknown</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T11 = unknown | undefined;  </span><span style=\"color: #008000\">// unknown</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T12 = unknown | null | undefined;  </span><span style=\"color: #008000\">// unknown</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T13 = unknown | string;  </span><span style=\"color: #008000\">// unknown</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T14 = unknown | string[];  </span><span style=\"color: #008000\">// unknown</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T15 = unknown | unknown;  </span><span style=\"color: #008000\">// unknown</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T16 = unknown | any;  </span><span style=\"color: #008000\">// any</span>\n\n<span style=\"color: #008000\">// Type variable and unknown in union and intersection</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T20&lt;T&gt; = T & {};  </span><span style=\"color: #008000\">// T & {}</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T21&lt;T&gt; = T | {};  </span><span style=\"color: #008000\">// T | {}</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T22&lt;T&gt; = T & unknown;  </span><span style=\"color: #008000\">// T</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T23&lt;T&gt; = T | unknown;  </span><span style=\"color: #008000\">// unknown</span>\n\n<span style=\"color: #008000\">// unknown in conditional types</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T30&lt;T&gt; = unknown extends T ? true : false;  </span><span style=\"color: #008000\">// Deferred</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T31&lt;T&gt; = T extends unknown ? true : false;  </span><span style=\"color: #008000\">// Deferred (so it distributes)</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T32&lt;T&gt; = never extends T ? true : false;  </span><span style=\"color: #008000\">// true</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T33&lt;T&gt; = T extends never ? true : false;  </span><span style=\"color: #008000\">// Deferred</span>\n\n<span style=\"color: #008000\">// keyof unknown</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T40 = </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> any;  </span><span style=\"color: #008000\">// string | number | symbol</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T41 = </span><span style=\"color: #0000FF\">keyof</span><span style=\"color: #000000\"> unknown;  </span><span style=\"color: #008000\">// never</span>\n\n<span style=\"color: #008000\">// Only equality operators are allowed with unknown</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f10(x: unknown) {</span>\n<span style=\"color: #000000\">    x == </span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    x !== </span><span style=\"color: #09835A\">10</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    x &gt;= </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">    x + </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">    x * </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">    -x;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">    +x;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// No property accesses, element accesses, or function calls</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f11(x: unknown) {</span>\n<span style=\"color: #000000\">    x.foo;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">    x[</span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">];  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">    x();  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> x();  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// typeof, instanceof, and user defined type predicates</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> isFunction(x: unknown): x </span><span style=\"color: #0000FF\">is</span><span style=\"color: #000000\"> Function;</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f20(x: unknown) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> x === </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\"> || </span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> x === </span><span style=\"color: #A31515\">\"number\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">        x;  </span><span style=\"color: #008000\">// string | number</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (x </span><span style=\"color: #0000FF\">instanceof</span><span style=\"color: #000000\"> Error) {</span>\n<span style=\"color: #000000\">        x;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (isFunction(x)) {</span>\n<span style=\"color: #000000\">        x;  </span><span style=\"color: #008000\">// Function</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Homomorphic mapped type over unknown</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T50&lt;T&gt; = { [P </span><span style=\"color: #0000FF\">in</span><span style=\"color: #000000\"> keyof T]: number };</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T51 = T50&lt;any&gt;;  </span><span style=\"color: #008000\">// { [x: string]: number }</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> T52 = T50&lt;unknown&gt;;  </span><span style=\"color: #008000\">// {}</span>\n\n<span style=\"color: #008000\">// Anything is assignable to unknown</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f21&lt;T&gt;(pAny: any, pNever: never, pT: T) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: unknown;</span>\n<span style=\"color: #000000\">    x = </span><span style=\"color: #09835A\">123</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    x = </span><span style=\"color: #A31515\">\"hello\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    x = [</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">];</span>\n<span style=\"color: #000000\">    x = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> Error();</span>\n<span style=\"color: #000000\">    x = x;</span>\n<span style=\"color: #000000\">    x = pAny;</span>\n<span style=\"color: #000000\">    x = pNever;</span>\n<span style=\"color: #000000\">    x = pT;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// unknown assignable only to itself and any</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f22(x: unknown) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v1: any = x;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v2: unknown = x;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v3: object = x;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v4: string = x;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v5: string[] = x;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v6: {} = x;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> v7: {} | null | undefined = x;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Type parameter 'T extends unknown' not related to object</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f23&lt;T </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> unknown&gt;(x: T) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> y: object = x;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Anything but primitive assignable to { [x: string]: unknown }</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f24(x: { [x: string]: unknown }) {</span>\n<span style=\"color: #000000\">    x = {};</span>\n<span style=\"color: #000000\">    x = { a: </span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #000000\">    x = [</span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">2</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">];</span>\n<span style=\"color: #000000\">    x = </span><span style=\"color: #09835A\">123</span><span style=\"color: #000000\">;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Locals of type unknown always considered initialized</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f25() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: unknown;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> y = x;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Spread of unknown causes result to be unknown</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f26(x: {}, y: unknown, z: any) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> o1 = { a: </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, ...x };  </span><span style=\"color: #008000\">// { a: number }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> o2 = { a: </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, ...x, ...y };  </span><span style=\"color: #008000\">// unknown</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> o3 = { a: </span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">, ...x, ...y, ...z };  </span><span style=\"color: #008000\">// any</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Functions with unknown return type don't need return expressions</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f27(): unknown {</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Rest type cannot be created from unknown</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f28(x: unknown) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> { ...a } = x;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Class properties of type unknown don't need definite assignment</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> C1 {</span>\n<span style=\"color: #000000\">    a: string;  </span><span style=\"color: #008000\">// Error</span>\n<span style=\"color: #000000\">    b: unknown;</span>\n<span style=\"color: #000000\">    c: any;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"support-for-defaultprops-in-jsx\" style=\"position:relative;\"><a href=\"#support-for-defaultprops-in-jsx\" aria-label=\"support for defaultprops in jsx permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Support for <code>defaultProps</code> in JSX</h2>\n<p>TypeScript 2.9 and earlier didn’t leverage <a href=\"https://reactjs.org/docs/typechecking-with-proptypes.html#default-prop-values\">React <code>defaultProps</code></a> declarations inside JSX components.\nUsers would often have to declare properties optional and use non-null assertions inside of <code>render</code>, or they’d use type-assertions to fix up the type of the component before exporting it.</p>\n<p>TypeScript 3.0 adds support for a new type alias in the <code>JSX</code> namespace called <code>LibraryManagedAttributes</code>.\nThis helper type defines a transformation on the component’s <code>Props</code> type, before using to check a JSX expression targeting it; thus allowing customization like: how conflicts between provided props and inferred props are handled, how inferences are mapped, how optionality is handled, and how inferences from differing places should be combined.</p>\n<p>In short using this general type, we can model React’s specific behavior for things like <code>defaultProps</code> and, to some extent, <code>propTypes</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">tsx</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Props {</span>\n<span style=\"color: #000000\">    name: string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Greet </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> React.Component&lt;Props&gt; {</span>\n<span style=\"color: #000000\">    render() {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> { name } = </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.props;</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #800000\">&lt;div&gt;</span><span style=\"color: #000000\">Hello {name.toUpperCase()}!</span><span style=\"color: #800000\">&lt;/div&gt;</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">static</span><span style=\"color: #000000\"> defaultProps = { name: </span><span style=\"color: #A31515\">\"world\"</span><span style=\"color: #000000\">};</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Type-checks! No type assertions needed!</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> el = </span><span style=\"color: #800000\">&lt;Greet</span><span style=\"color: #000000\"> </span><span style=\"color: #800000\">/&gt;</span></code></div></pre>\n<h2 id=\"caveats\" style=\"position:relative;\"><a href=\"#caveats\" aria-label=\"caveats permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Caveats</h2>\n<h3 id=\"explicit-types-on-defaultprops\" style=\"position:relative;\"><a href=\"#explicit-types-on-defaultprops\" aria-label=\"explicit types on defaultprops permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Explicit types on <code>defaultProps</code></h3>\n<p>The default-ed properties are inferred from the <code>defaultProps</code> property type. If an explicit type annotation is added, e.g. <code>static defaultProps: Partial&#x3C;Props>;</code> the compiler will not be able to identify which properties have defaults (since the type of <code>defaultProps</code> include all properties of <code>Props</code>).</p>\n<p>Use <code>static defaultProps: Pick&#x3C;Props, \"name\">;</code> as an explicit type annotation instead, or do not add a type annotation as done in the example above.</p>\n<p>For function components (formerly known as SFCs) use ES2015 default initializers:</p>\n<pre class=\"shiki\"><div class=\"language-id\">tsx</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> Greet({ name = </span><span style=\"color: #A31515\">\"world\"</span><span style=\"color: #000000\"> }: Props) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #800000\">&lt;div&gt;</span><span style=\"color: #000000\">Hello {name.toUpperCase()}!</span><span style=\"color: #800000\">&lt;/div&gt;</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h4 id=\"changes-to-typesreact\" style=\"position:relative;\"><a href=\"#changes-to-typesreact\" aria-label=\"changes to typesreact permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Changes to <code>@types/React</code></h4>\n<p>Corresponding changes to add <code>LibraryManagedAttributes</code> definition to the <code>JSX</code> namespace in <code>@types/React</code> are still needed.\nKeep in mind that there are some limitations.</p>\n<h2 id=\"-reference-lib--reference-directives\" style=\"position:relative;\"><a href=\"#-reference-lib--reference-directives\" aria-label=\" reference lib  reference directives permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>/// &#x3C;reference lib=\"...\" /></code> reference directives</h2>\n<p>TypeScript adds a new triple-slash-reference directive (<code>/// &#x3C;reference lib=\"name\" /></code>), allowing a file to explicitly include an existing built-in <em>lib</em> file.</p>\n<p>Built-in <em>lib</em> files are referenced in the same fashion as the <code>\"lib\"</code> compiler option in <em>tsconfig.json</em> (e.g. use <code>lib=\"es2015\"</code> and not <code>lib=\"lib.es2015.d.ts\"</code>, etc.).</p>\n<p>For declaration file authors who relay on built-in types, e.g. DOM APIs or built-in JS run-time constructors like <code>Symbol</code> or <code>Iterable</code>, triple-slash-reference lib directives are the recommended. Previously these .d.ts files had to add forward/duplicate declarations of such types.</p>\n<h5 id=\"example-4\" style=\"position:relative;\"><a href=\"#example-4\" aria-label=\"example 4 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h5>\n<p>Using <code>/// &#x3C;reference lib=\"es2017.string\" /></code> to one of the files in a compilation is equivalent to compiling with <code>--lib es2017.string</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">/// &lt;reference lib=\"es2017.string\" /&gt;</span>\n\n<span style=\"color: #A31515\">\"foo\"</span><span style=\"color: #000000\">.padStart(</span><span style=\"color: #09835A\">4</span><span style=\"color: #000000\">);</span></code></div></pre>","headings":[{"value":"Project References","depth":2},{"value":"Tuples in rest parameters and spread expressions","depth":2},{"value":"Rest parameters with tuple types","depth":2},{"value":"Spread expressions with tuple types","depth":2},{"value":"Generic rest parameters","depth":2},{"value":"Example","depth":5},{"value":"Optional elements in tuple types","depth":2},{"value":"Example","depth":5},{"value":"Rest elements in tuple types","depth":3},{"value":"Example","depth":5},{"value":"New unknown top type","depth":2},{"value":"Example","depth":5},{"value":"Support for defaultProps in JSX","depth":2},{"value":"Caveats","depth":2},{"value":"Explicit types on defaultProps","depth":3},{"value":"Changes to @types/React","depth":4},{"value":"/// <reference lib=\"...\" /> reference directives","depth":2},{"value":"Example","depth":5}],"frontmatter":{"permalink":"/docs/handbook/release-notes/typescript-3-0.html","title":"TypeScript 3.0"}}},"pageContext":{"slug":"/docs/handbook/release-notes/typescript-3-0.html","isOldHandbook":true}}}