{"componentChunkName":"component---src-templates-handbook-tsx","path":"/docs/handbook/typescript-in-5-minutes.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":"d4f9fd14-f3a9-5eec-bd7a-6ed9f55057d2","excerpt":"The relationship between TypeScript and JavaScript is rather unique among modern programming languages.\nTypeScript sits as a layer on-top of JavaScript…","html":"<p>The relationship between TypeScript and JavaScript is rather unique among modern programming languages.\nTypeScript sits as a layer on-top of JavaScript, offering the features of JavaScript and then adds it’s own layer on top of that. This layer is the TypeScript type system.</p>\n<p>JavaScript already has a set of language primitives like <code>string</code>, <code>number</code>, <code>object</code>, <code>undefined</code> etc, however there are no ahead-of-time checks that these are consistently assigned across your whole codebase. TypeScript acts as that layer.</p>\n<p>This means that your existing working JavaScript code is also TypeScript code, however TypeScript’s type-checker might highlight discrepancies between what you thought was happening and what the JavaScript language does.</p>\n<p>This tutorial tries to give you a 5 minute overview of the type-system, with a focus on understanding the type-system langauge extensions which TypeScript adds.</p>\n<h2 id=\"types-by-inference\" style=\"position:relative;\"><a href=\"#types-by-inference\" aria-label=\"types by inference permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Types by Inference</h2>\n<p>TypeScript knows the JavaScript language and will generate types for you in many cases.\nFor example in creating a variable and assigning it to a particular value, TypeScript will use the value as its type.</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> <span class='lsp'>helloWorld <span class='lsp-result'>let helloWorld: string</span></span>= </span><span style=\"color: #A31515\">\"Hello World\"</span><span style=\"color: #000000\">;</span>\n<span class='query'>//  ^ = let helloWorld: string</span></code></div></pre>\n<p>By understanding how JavaScript works, TypeScript can build a type-system which accepts JavaScript code but has types. This offers a type-system without needed to add extra characters to make types explicit in your code. Which is how TypeScript knows that <code>helloWorld</code> is a <code>string</code> in the above example.</p>\n<p>It’s quite possible that you have used VS Code with JavaScript, and had editor auto-completion as you worked.\nThat is because the understanding of JavaScript baked into TypeScript has been used under-the-hood to improve working with JavaScript.</p>\n<h2 id=\"defining-types\" style=\"position:relative;\"><a href=\"#defining-types\" aria-label=\"defining 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>Defining Types</h2>\n<p>JavaScript is a dynamic language which allows for a lot of design patterns. Some design patterns can be hard to automatically provide types for automatically (because they might use dynamic programming) in those cases TypeScript supports an extension of the JavaScript language which offers places for you to tell TypeScript what the types should be.</p>\n<p>Here is an example of creating an object which has an inferred type which includes <code>name: string</code> and <code>id: number</code>:</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> <span class='lsp'>user <span class='lsp-result'>const user: {&#13;    name: string;&#13;    id: number;&#13;}</span></span>= {</span>\n<span style=\"color: #000000\">  <span class='lsp'>name:<span class='lsp-result'>(property) name: string</span></span></span><span style=\"color: #A31515\">\"Hayes\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  <span class='lsp'>id:<span class='lsp-result'>(property) id: number</span></span></span><span style=\"color: #09835A\">0</span>\n<span style=\"color: #000000\">};</span></code></div></pre>\n<p>An explicit way to describe this object’s shape is via an <code>interface</code> declaration:</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> <span class='lsp'>User <span class='lsp-result'>interface User</span></span></span>\n<span style=\"color: #000000\">  <span class='lsp'>name:<span class='lsp-result'>(property) User.name: string</span></span> string;</span>\n<span style=\"color: #000000\">  <span class='lsp'>id:<span class='lsp-result'>(property) User.id: number</span></span> number;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>You can then declare that a JavaScript object conforms to that shape of your new <code>interface</code> by using syntax like <code>: TypeName</code> after a variable declaration:</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> user: User = {</span>\n<span style=\"color: #000000\">  name: </span><span style=\"color: #A31515\">\"Hayes\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  id: </span><span style=\"color: #09835A\">0</span>\n<span style=\"color: #000000\">};</span></code></div></pre>\n<p>TypeScript will warn you if you provide an object which doesn’t match the interface you have provided:</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> <span class='lsp'>User <span class='lsp-result'>interface User</span></span></span>\n<span style=\"color: #000000\">  <span class='lsp'>name:<span class='lsp-result'>(property) User.name: string</span></span> string;</span>\n<span style=\"color: #000000\">  <span class='lsp'>id:<span class='lsp-result'>(property) User.id: number</span></span> number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> <span class='lsp'>user:<span class='lsp-result'>const user: User</span></span> <span class='lsp'>User <span class='lsp-result'>interface User</span></span>= {</span>\n<span style=\"color: #000000\">  <span class='lsp'>username:<span class='lsp-result'>(property) username: string</span></span></span><span style=\"color: #A31515\">\"Hayes\"</span><span style=\"color: #000000\">,</span>\n<span class=\"error\"><span>Type '{ username: string; id: number; }' is not assignable to type 'User'.\n  Object literal may only specify known properties, and 'username' does not exist in type 'User'.</span><span class=\"code\">2322</span></span><span class=\"error-behind\">Type '{ username: string; id: number; }' is not assignable to type 'User'.\n  Object literal may only specify known properties, and 'username' does not exist in type 'User'.</span><span style=\"color: #000000\">  <span class='lsp'>id:<span class='lsp-result'>(property) User.id: number</span></span></span><span style=\"color: #09835A\">0</span>\n<span style=\"color: #000000\">};</span></code></div></pre>\n<p>Because JavaScript supports classes and object-orient programming, so does TypeScript - a interface declaration can also be used with classes:</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> <span class='lsp'>User <span class='lsp-result'>interface User</span></span></span>\n<span style=\"color: #000000\">  <span class='lsp'>name:<span class='lsp-result'>(property) User.name: string</span></span> string;</span>\n<span style=\"color: #000000\">  <span class='lsp'>id:<span class='lsp-result'>(property) User.id: number</span></span> number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> <span class='lsp'>UserAccount <span class='lsp-result'>class UserAccount</span></span></span>\n<span style=\"color: #000000\">  <span class='lsp'>name:<span class='lsp-result'>(property) UserAccount.name: string</span></span> string;</span>\n<span style=\"color: #000000\">  <span class='lsp'>id:<span class='lsp-result'>(property) UserAccount.id: number</span></span> number;</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(<span class='lsp'>name:<span class='lsp-result'>(parameter) name: string</span></span> string, <span class='lsp'>id:<span class='lsp-result'>(parameter) id: number</span></span> number) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.<span class='lsp'>name <span class='lsp-result'>(property) UserAccount.name: string</span></span>= <span class='lsp'>name;<span class='lsp-result'>(parameter) name: string</span></span></span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.<span class='lsp'>id <span class='lsp-result'>(property) UserAccount.id: number</span></span>= <span class='lsp'>id;<span class='lsp-result'>(parameter) id: number</span></span></span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> <span class='lsp'>user:<span class='lsp-result'>const user: User</span></span> <span class='lsp'>User <span class='lsp-result'>interface User</span></span>= </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> <span class='lsp'>UserAccount(<span class='lsp-result'>constructor UserAccount(name: string, id: number): UserAccount</span></span></span><span style=\"color: #A31515\">\"Murphy\"</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">);</span></code></div></pre>\n<p>Interfaces can be used to annotate parameters and return values to functions:</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> getAdminUser(): User {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">//...</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> deleteUser(user: User) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #008000\">// ...</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>There are already a small set of primitive types available in JavaScript: <code>boolean</code>, <code>bigint</code>, <code>null</code>, <code>number</code>, <code>string</code>, <code>symbol</code>, <code>object</code> and <code>undefined</code>, which you can use in an interface. TypeScript extends this list with a few more. for example: <code>any</code> (allow anything), <a href=\"/en/play#example/unknown-and-never\"><code>unknown</code></a> (ensure someone using this type declares what the type is), <a href=\"/en/play#example/unknown-and-never\"><code>never</code></a> (it’s not possible that this type could happen) <code>void</code> (a function which returns <code>undefined</code> or has no return value).</p>\n<p>You’ll see quite quickly that there are two syntaxes for building types: <a href=\"/play/?e=83#example/types-vs-interfaces\">Interfaces and Types</a> - you should prefer <code>interface</code>, and use <code>type</code> when you need specific features.</p>\n<h2 id=\"composing-types\" style=\"position:relative;\"><a href=\"#composing-types\" aria-label=\"composing 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>Composing Types</h2>\n<p>Similar to how you would create larger complex objects by composing the, together TypeScript has tools for doing this with types.\nThe two most popular techniques you would use in everyday code every to create new types by working with many smaller types are Unions and Generics.</p>\n<h3 id=\"unions\" style=\"position:relative;\"><a href=\"#unions\" aria-label=\"unions 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>Unions</h3>\n<p>A union is a way to declare that a type could be one of many types. For example, you could describe a <code>boolean</code> type as being either <code>true</code> or <code>false</code>:</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> <span class='lsp'>MyBool <span class='lsp-result'>type MyBool = boolean</span></span>= true | false;</span></code></div></pre>\n<p><em>Note:</em> If you hover over <code>MyBool</code> above, you’ll see that it is classed as <code>boolean</code> - that’s an property of the Structural Type System, which we’ll get to later.</p>\n<p>One of the most popular use-cases for union types is to describe a set of <code>string</code>s or <code>number</code>s <a href=\"/handbook/literal-types.html\">literal</a> which a value is allowed to be:</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> <span class='lsp'>WindowStates <span class='lsp-result'>type WindowStates = &quot;open&quot; | &quot;closed&quot; | &quot;minimized&quot;</span></span>= </span><span style=\"color: #A31515\">\"open\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"closed\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"minimized\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> <span class='lsp'>LockStates <span class='lsp-result'>type LockStates = &quot;locked&quot; | &quot;unlocked&quot;</span></span>= </span><span style=\"color: #A31515\">\"locked\"</span><span style=\"color: #000000\"> | </span><span style=\"color: #A31515\">\"unlocked\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> <span class='lsp'>OddNumbersUnderTen <span class='lsp-result'>type OddNumbersUnderTen = 1 | 3 | 5 | 7 | 9</span></span>= </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\"> | </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\"> | </span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\"> | </span><span style=\"color: #09835A\">7</span><span style=\"color: #000000\"> | </span><span style=\"color: #09835A\">9</span><span style=\"color: #000000\">;</span></code></div></pre>\n<p>Unions provide a way to handle different types too, for example you may have a function which accepts an <code>array</code> or a <code>string</code>.</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> <span class='lsp'>getLength(<span class='lsp-result'>function getLength(obj: string | string[]): string | string[]</span></span><span class='lsp'>obj:<span class='lsp-result'>(parameter) obj: string | string[]</span></span> string | string[]) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> <span class='lsp'>obj;<span class='lsp-result'>(parameter) obj: string | string[]</span></span></span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>TypeScript understands how code changes what the variable could be with time, you can use these checks to narrow the type down.</p>\n<table>\n<thead>\n<tr>\n<th>Type</th>\n<th>Predicate</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>string</td>\n<td><code>typeof s === \"string\"</code></td>\n</tr>\n<tr>\n<td>number</td>\n<td><code>typeof n === \"number\"</code></td>\n</tr>\n<tr>\n<td>boolean</td>\n<td><code>typeof b === \"boolean\"</code></td>\n</tr>\n<tr>\n<td>undefined</td>\n<td><code>typeof undefined === \"undefined\"</code></td>\n</tr>\n<tr>\n<td>function</td>\n<td><code>typeof f === \"function\"</code></td>\n</tr>\n<tr>\n<td>array</td>\n<td><code>Array.isArray(a)</code></td>\n</tr>\n</tbody>\n</table>\n<p>For example, you could differentiate between a <code>string</code> and an <code>array</code>, using <code>typeof obj === \"string\"</code> and TypeScript will know what the object is down different code paths.</p>\n<!-- prettier-ignore -->\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> <span class='lsp'>wrapInArray(<span class='lsp-result'>function wrapInArray(obj: string | string[]): string[]</span></span><span class='lsp'>obj:<span class='lsp-result'>(parameter) obj: string | string[]</span></span> string | string[]) {</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\"> <span class='lsp'>obj <span class='lsp-result'>(parameter) obj: string | string[]</span></span>=== </span><span style=\"color: #A31515\">\"string\"</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> [<span class='lsp'>obj]<span class='lsp-result'>(parameter) obj: string</span></span></span>\n<span class='query'>//          ^ = (parameter) obj: string</span>\n<span style=\"color: #000000\">  } </span><span style=\"color: #0000FF\">else</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> <span class='lsp'>obj;<span class='lsp-result'>(parameter) obj: string[]</span></span></span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h3 id=\"generics\" style=\"position:relative;\"><a href=\"#generics\" aria-label=\"generics 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>Generics</h3>\n<p>You can get very deep into the TypeScript generic system, but at a 1 minute high-level explanation, generics are a way to provide variables to types.</p>\n<p>A common example is an array, an array without generics could contain anything. An array with generics can describe what values are inside in the array.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> StringArray = Array&lt;string&gt;;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> NumberArray = Array&lt;number&gt;;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> ObjectWithNameArray = Array&lt;{ name: string }&gt;;</span></code></div></pre>\n<p>You can declare your own types which use generics:</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> <span class='lsp'>Backpack&lt;<span class='lsp-result'>interface Backpack&lt;Type&gt;</span></span><span class='lsp'>Type&gt;<span class='lsp-result'>(type parameter) Type in Backpack&lt;Type&gt;</span></span> {</span>\n<span style=\"color: #000000\">  <span class='lsp'>add:<span class='lsp-result'>(property) Backpack&lt;Type&gt;.add: (obj: Type) =&gt; void</span></span> (<span class='lsp'>obj:<span class='lsp-result'>(parameter) obj: Type</span></span> <span class='lsp'>Type)<span class='lsp-result'>(type parameter) Type in Backpack&lt;Type&gt;</span></span></span><span style=\"color: #0000FF\">=></span><span style=\"color: #000000\"> void;</span>\n<span style=\"color: #000000\">  <span class='lsp'>get:<span class='lsp-result'>(property) Backpack&lt;Type&gt;.get: () =&gt; Type</span></span> () </span><span style=\"color: #0000FF\">=></span><span style=\"color: #000000\"> <span class='lsp'>Type;<span class='lsp-result'>(type parameter) Type in Backpack&lt;Type&gt;</span></span></span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// This line is a shortcut to tell TypeScript there is a</span>\n<span style=\"color: #008000\">// constant called `backpack`, and to not worry about where it came from</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> <span class='lsp'>backpack:<span class='lsp-result'>const backpack: Backpack&lt;string&gt;</span></span> <span class='lsp'>Backpack&lt;<span class='lsp-result'>interface Backpack&lt;Type&gt;</span></span>string&gt;;</span>\n\n<span style=\"color: #008000\">// object is a string, because we declared it above as the variable part of Backpack</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> <span class='lsp'>object <span class='lsp-result'>const object: string</span></span>= <span class='lsp'>backpack.<span class='lsp-result'>const backpack: Backpack&lt;string&gt;</span></span><span class='lsp'>get(<span class='lsp-result'>(property) Backpack&lt;string&gt;.get: () =&gt; string</span></span>);</span>\n\n<span style=\"color: #008000\">// Due to backpack variable being a string, you cannot pass a number to the add function</span>\n<span style=\"color: #000000\"><span class='lsp'>backpack.<span class='lsp-result'>const backpack: Backpack&lt;string&gt;</span></span><span class='lsp'>add(<span class='lsp-result'>(property) Backpack&lt;string&gt;.add: (obj: string) =&gt; void</span></span></span><span style=\"color: #09835A\"><span class='err'>23</span></span><span style=\"color: #000000\">);</span>\n<span class=\"error\"><span>Argument of type '23' is not assignable to parameter of type 'string'.</span><span class=\"code\">2345</span></span><span class=\"error-behind\">Argument of type '23' is not assignable to parameter of type 'string'.</span></code></div></pre>\n<h2 id=\"structural-type-system\" style=\"position:relative;\"><a href=\"#structural-type-system\" aria-label=\"structural type system 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>Structural Type System</h2>\n<p>One of TypeScript’s core principles is that type checking focuses on the <em>shape</em> which values have.\nThis is sometimes called “duck typing” or “structural typing”.</p>\n<p>In a structural type system if two objects have the same shape, they are considered the same.</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> <span class='lsp'>Point <span class='lsp-result'>interface Point</span></span></span>\n<span style=\"color: #000000\">  <span class='lsp'>x:<span class='lsp-result'>(property) Point.x: number</span></span> number;</span>\n<span style=\"color: #000000\">  <span class='lsp'>y:<span class='lsp-result'>(property) Point.y: number</span></span> number;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> <span class='lsp'>printPoint(<span class='lsp-result'>function printPoint(p: Point): void</span></span><span class='lsp'>p:<span class='lsp-result'>(parameter) p: Point</span></span> <span class='lsp'>Point)<span class='lsp-result'>interface Point</span></span> {</span>\n<span style=\"color: #000000\">  <span class='lsp'>console.<span class='lsp-result'>var console: Console</span></span><span class='lsp'>log(<span class='lsp-result'>(method) Console.log(message?: any, ...optionalParams: any[]): void</span></span></span><span style=\"color: #A31515\">`</span><span style=\"color: #0000FF\">${</span><span style=\"color: #A31515\"><span class='lsp'>p.<span class='lsp-result'>(parameter) p: Point</span></span><span class='lsp'>x<span class='lsp-result'>(property) Point.x: number</span></span></span><span style=\"color: #0000FF\">}</span><span style=\"color: #A31515\">, </span><span style=\"color: #0000FF\">${</span><span style=\"color: #A31515\"><span class='lsp'>p.<span class='lsp-result'>(parameter) p: Point</span></span><span class='lsp'>y<span class='lsp-result'>(property) Point.y: number</span></span></span><span style=\"color: #0000FF\">}</span><span style=\"color: #A31515\">`</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// prints \"12, 26\"</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> <span class='lsp'>point <span class='lsp-result'>const point: {&#13;    x: number;&#13;    y: number;&#13;}</span></span>= { <span class='lsp'>x:<span class='lsp-result'>(property) x: number</span></span></span><span style=\"color: #09835A\">12</span><span style=\"color: #000000\">, <span class='lsp'>y:<span class='lsp-result'>(property) y: number</span></span></span><span style=\"color: #09835A\">26</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #000000\"><span class='lsp'>printPoint(<span class='lsp-result'>function printPoint(p: Point): void</span></span><span class='lsp'>point)<span class='lsp-result'>const point: {&#13;    x: number;&#13;    y: number;&#13;}</span></span></span></code></div></pre>\n<p>The <code>point</code> variable is never declared to be a <code>Point</code> type, but because TypeScript compares the shape of <code>point</code> to the shape of <code>Point</code> in the type-check.\nBecause they both have the same shape, then it passes.</p>\n<p>The shape matching only requires a subset of the object’s fields to match.</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> point3 = { x: </span><span style=\"color: #09835A\">12</span><span style=\"color: #000000\">, y: </span><span style=\"color: #09835A\">26</span><span style=\"color: #000000\">, z: </span><span style=\"color: #09835A\">89</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #000000\">printPoint(point3); </span><span style=\"color: #008000\">// prints \"12, 26\"</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> rect = { x: </span><span style=\"color: #09835A\">33</span><span style=\"color: #000000\">, y: </span><span style=\"color: #09835A\">3</span><span style=\"color: #000000\">, width: </span><span style=\"color: #09835A\">30</span><span style=\"color: #000000\">, height: </span><span style=\"color: #09835A\">80</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #000000\">printPoint(rect); </span><span style=\"color: #008000\">// prints \"33, 3\"</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> color = { hex: </span><span style=\"color: #A31515\">\"#187ABF\"</span><span style=\"color: #000000\"> };</span>\n<span style=\"color: #008000\">// Errors: Argument of type '{ hex: string; }' is not assignable to parameter of type 'Point'.</span>\n<span style=\"color: #000000\">printPoint(color);</span></code></div></pre>\n<p>This is a high level 5 minute overview of the sort of syntax and tools you would use in everyday code.\nFrom here you should read <a href=\"/docs/handbook/basic-types.html\">through the handbook</a> or explore the <a href=\"/play#show-examples\">Playground examples</a>.</p>","headings":[{"value":"Types by Inference","depth":2},{"value":"Defining Types","depth":2},{"value":"Composing Types","depth":2},{"value":"Unions","depth":3},{"value":"Generics","depth":3},{"value":"Structural Type System","depth":2}],"frontmatter":{"permalink":"/docs/handbook/typescript-in-5-minutes.html","title":"TypeScript for JavaScript Programmers"}}},"pageContext":{"slug":"/docs/handbook/typescript-in-5-minutes.html","isOldHandbook":true}}}