{"componentChunkName":"component---src-templates-handbook-tsx","path":"/docs/handbook/release-notes/typescript-3-6.html","result":{"data":{"allSitePage":{"nodes":[{"path":"/dev-404-page/"},{"path":"/docs/handbook/advanced-types.html"},{"path":"/docs/handbook/basic-types.html"},{"path":"/docs/handbook/classes.html"},{"path":"/docs/handbook/compiler-options-in-msbuild.html"},{"path":"/docs/handbook/compiler-options.html"},{"path":"/docs/handbook/configuring-watch.html"},{"path":"/docs/handbook/declaration-merging.html"},{"path":"/docs/handbook/decorators.html"},{"path":"/docs/handbook/enums.html"},{"path":"/docs/handbook/functions.html"},{"path":"/docs/handbook/generics.html"},{"path":"/docs/handbook/integrating-with-build-tools.html"},{"path":"/docs/handbook/interfaces.html"},{"path":"/docs/handbook/iterators-and-generators.html"},{"path":"/docs/handbook/jsdoc-supported-types.html"},{"path":"/docs/handbook/jsx.html"},{"path":"/docs/handbook/literal-types.html"},{"path":"/docs/handbook/mixins.html"},{"path":"/docs/handbook/module-resolution.html"},{"path":"/docs/handbook/modules.html"},{"path":"/docs/handbook/namespaces-and-modules.html"},{"path":"/docs/handbook/namespaces.html"},{"path":"/docs/handbook/nightly-builds.html"},{"path":"/docs/handbook/project-references.html"},{"path":"/docs/handbook/symbols.html"},{"path":"/docs/handbook/"},{"path":"/docs/handbook/triple-slash-directives.html"},{"path":"/docs/handbook/type-checking-javascript-files.html"},{"path":"/docs/handbook/type-compatibility.html"},{"path":"/docs/handbook/type-inference.html"},{"path":"/docs/handbook/unions-and-intersections.html"},{"path":"/docs/handbook/utility-types.html"},{"path":"/docs/handbook/variable-declarations.html"},{"path":"/docs/handbook/writing-declaration-files.html"},{"path":"/docs/handbook/declaration-files/by-example.html"},{"path":"/docs/handbook/declaration-files/consumption.html"},{"path":"/docs/handbook/declaration-files/deep-dive.html"},{"path":"/docs/handbook/declaration-files/do-s-and-don-ts.html"},{"path":"/docs/handbook/declaration-files/introduction.html"},{"path":"/docs/handbook/declaration-files/library-structures.html"},{"path":"/docs/handbook/declaration-files/publishing.html"},{"path":"/docs/handbook/declaration-files/templates.html"},{"path":"/docs/handbook/release-notes/typescript-1-1.html"},{"path":"/docs/handbook/release-notes/typescript-1-3.html"},{"path":"/docs/handbook/release-notes/typescript-1-4.html"},{"path":"/docs/handbook/release-notes/typescript-1-5.html"},{"path":"/docs/handbook/release-notes/typescript-1-6.html"},{"path":"/docs/handbook/release-notes/typescript-1-7.html"},{"path":"/docs/handbook/release-notes/typescript-1-8.html"},{"path":"/docs/handbook/release-notes/typescript-2-0.html"},{"path":"/docs/handbook/release-notes/typescript-2-2.html"},{"path":"/docs/handbook/release-notes/typescript-2-1.html"},{"path":"/docs/handbook/release-notes/typescript-2-3.html"},{"path":"/docs/handbook/release-notes/typescript-2-4.html"},{"path":"/docs/handbook/release-notes/typescript-2-5.html"},{"path":"/docs/handbook/release-notes/typescript-2-6.html"},{"path":"/docs/handbook/release-notes/typescript-2-7.html"},{"path":"/docs/handbook/release-notes/typescript-2-8.html"},{"path":"/docs/handbook/release-notes/typescript-2-9.html"},{"path":"/docs/handbook/release-notes/typescript-3-0.html"},{"path":"/docs/handbook/release-notes/typescript-3-1.html"},{"path":"/docs/handbook/release-notes/typescript-3-2.html"},{"path":"/docs/handbook/release-notes/typescript-3-3.html"},{"path":"/docs/handbook/release-notes/typescript-3-4.html"},{"path":"/docs/handbook/release-notes/typescript-3-5.html"},{"path":"/docs/handbook/release-notes/typescript-3-6.html"},{"path":"/docs/handbook/release-notes/typescript-3-7.html"},{"path":"/docs/handbook/release-notes/typescript-3-8.html"},{"path":"/docs/handbook/asp-net-core.html"},{"path":"/docs/handbook/angular.html"},{"path":"/docs/handbook/dom-manipulation.html"},{"path":"/docs/handbook/gulp.html"},{"path":"/docs/handbook/migrating-from-javascript.html"},{"path":"/docs/handbook/react-&-webpack.html"},{"path":"/docs/handbook/react.html"},{"path":"/docs/handbook/typescript-in-5-minutes-func.html"},{"path":"/docs/handbook/typescript-in-5-minutes.html"},{"path":"/docs/handbook/typescript-in-5-minutes-oop.html"},{"path":"/docs/handbook/typescript-from-scratch.html"},{"path":"/docs/handbook/typescript-tooling-in-5-minutes.html"},{"path":"/docs/handbook/tsconfig-json.html"},{"path":"/docs/handbook/declaration-files/templates/global-modifying-module-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/global-plugin-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/global-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/module-class-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/module-function-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/module-plugin-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/module-d-ts.html"},{"path":"/docs/handbook/release-notes/overview.html"},{"path":"/tsconfig"},{"path":"/en/tsconfig"},{"path":"/ja/tsconfig"},{"path":"/vo/tsconfig"},{"path":"/play"},{"path":"/en/play"},{"path":"/es/play"},{"path":"/vo/play"},{"path":"/zh/play"},{"path":"/ja/play"},{"path":"/play/3-7/fixits/big-number-literals.ts"},{"path":"/play/3-7/fixits/const-to-let.ts"},{"path":"/play/3-7/fixits/infer-from-usage-changes.ts"},{"path":"/play/3-7/syntax-and-messaging/flattened-error-reporting.ts"},{"path":"/play/3-7/syntax-and-messaging/nullish-coalescing.ts"},{"path":"/play/3-7/syntax-and-messaging/optional-chaining.ts"},{"path":"/play/3-7/types-and-code-flow/assertion-functions.ts"},{"path":"/play/3-7/types-and-code-flow/recursive-type-references.ts"},{"path":"/play/3-7/types-and-code-flow/uncalled-function-checks.ts"},{"path":"/play/3-8/breaking-changes/checking-unions-with-index-signatures.ts"},{"path":"/play/3-8/jsdoc-improvements/accessibility-modifiers.js"},{"path":"/play/3-8/syntax-and-messaging/export-modules-from.ts"},{"path":"/play/3-8/syntax-and-messaging/private-class-fields.ts"},{"path":"/play/javascript/external-apis/typescript-with-deno.ts"},{"path":"/play/javascript/external-apis/typescript-with-node.js"},{"path":"/play/javascript/external-apis/typescript-with-web.js"},{"path":"/play/javascript/external-apis/typescript-with-webgl.js"},{"path":"/play/javascript/functions-with-javascript/function-chaining.ts"},{"path":"/play/javascript/functions-with-javascript/generic-functions.ts"},{"path":"/play/javascript/functions-with-javascript/typing-functions.ts"},{"path":"/play/javascript/helping-with-javascript/errors.ts"},{"path":"/play/javascript/helping-with-javascript/quick-fixes.ts"},{"path":"/play/javascript/javascript-essentials/code-flow.ts"},{"path":"/play/javascript/javascript-essentials/functions.ts"},{"path":"/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/play/javascript/modern-javascript/async-await.ts"},{"path":"/play/javascript/modern-javascript/immutability.ts"},{"path":"/play/javascript/modern-javascript/import-export.ts"},{"path":"/play/javascript/modern-javascript/jsdoc-support.js"},{"path":"/play/javascript/working-with-classes/classes-101.ts"},{"path":"/play/javascript/working-with-classes/generic-classes.ts"},{"path":"/play/javascript/working-with-classes/mixins.ts"},{"path":"/play/javascript/working-with-classes/this.ts"},{"path":"/play/playground/config/javascript-playgrounds.js"},{"path":"/play/playground/config/new-compiler-defaults.ts"},{"path":"/play/playground/language/automatic-type-acquisition.ts"},{"path":"/play/playground/language/fixits.ts"},{"path":"/play/playground/tooling/mobile-support.ts"},{"path":"/play/playground/tooling/sharable-urls.ts"},{"path":"/play/playground/tooling/typescript-versions.ts"},{"path":"/play/typescript/language/soundness.ts"},{"path":"/play/typescript/language/structural-typing.ts"},{"path":"/play/typescript/language/type-guards.ts"},{"path":"/play/typescript/language/type-widening-and-narrowing.ts"},{"path":"/play/typescript/language-extensions/enums.ts"},{"path":"/play/typescript/language-extensions/nominal-typing.ts"},{"path":"/play/typescript/language-extensions/types-vs-interfaces.ts"},{"path":"/play/typescript/meta-types/conditional-types.ts"},{"path":"/play/typescript/meta-types/discriminate-types.ts"},{"path":"/play/typescript/meta-types/indexed-types.ts"},{"path":"/play/typescript/meta-types/mapped-types.ts"},{"path":"/play/typescript/primitives/any.ts"},{"path":"/play/typescript/primitives/literals.ts"},{"path":"/play/typescript/primitives/union-and-intersection-types.ts"},{"path":"/play/typescript/primitives/unknown-and-never.ts"},{"path":"/play/typescript/type-primitives/built-in-utility-types.ts"},{"path":"/play/typescript/type-primitives/nullable-types.ts"},{"path":"/play/typescript/type-primitives/tuples.ts"},{"path":"/es/play/javascript/external-apis/typescript-with-deno.ts"},{"path":"/es/play/javascript/external-apis/typescript-with-node.js"},{"path":"/es/play/javascript/external-apis/typescript-with-web.js"},{"path":"/es/play/javascript/functions-with-javascript/function-chaining.ts"},{"path":"/es/play/javascript/functions-with-javascript/generic-functions.ts"},{"path":"/es/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/es/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/es/play/typescript/type-primitives/built-in-utility-types.ts"},{"path":"/es/play/typescript/type-primitives/nullable-types.ts"},{"path":"/es/play/typescript/type-primitives/tuples.ts"},{"path":"/ja/play/typescript/language-extensions/enums.ts"},{"path":"/ja/play/typescript/language-extensions/nominal-typing.ts"},{"path":"/ja/play/typescript/language-extensions/types-vs-interfaces.ts"},{"path":"/ja/play/typescript/primitives/any.ts"},{"path":"/ja/play/typescript/primitives/literals.ts"},{"path":"/ja/play/typescript/primitives/union-and-intersection-types.ts"},{"path":"/ja/play/typescript/type-primitives/built-in-utility-types.ts"},{"path":"/vo/play/javascript/javascript-essentials/code-flow.ts"},{"path":"/vo/play/javascript/javascript-essentials/functions.ts"},{"path":"/vo/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/vo/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/zh/play/javascript/external-apis/typescript-with-deno.ts"},{"path":"/zh/play/javascript/external-apis/typescript-with-node.js"},{"path":"/zh/play/javascript/external-apis/typescript-with-web.js"},{"path":"/zh/play/javascript/external-apis/typescript-with-webgl.js"},{"path":"/zh/play/javascript/functions-with-javascript/function-chaining.ts"},{"path":"/zh/play/javascript/functions-with-javascript/generic-functions.ts"},{"path":"/zh/play/javascript/functions-with-javascript/typing-functions.ts"},{"path":"/zh/play/javascript/helping-with-javascript/errors.ts"},{"path":"/zh/play/javascript/helping-with-javascript/quick-fixes.ts"},{"path":"/zh/play/javascript/javascript-essentials/code-flow.ts"},{"path":"/zh/play/javascript/javascript-essentials/functions.ts"},{"path":"/zh/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/zh/play/javascript/modern-javascript/import-export.ts"},{"path":"/zh/play/javascript/modern-javascript/jsdoc-support.js"},{"path":"/zh/play/javascript/working-with-classes/classes-101.ts"},{"path":"/zh/play/javascript/working-with-classes/generic-classes.ts"},{"path":"/zh/play/javascript/working-with-classes/mixins.ts"},{"path":"/zh/play/javascript/working-with-classes/this.ts"},{"path":"/zh/play/playground/config/javascript-playgrounds.js"},{"path":"/zh/play/playground/config/new-compiler-defaults.ts"},{"path":"/zh/play/playground/language/automatic-type-acquisition.ts"},{"path":"/zh/play/playground/language/fixits.ts"},{"path":"/zh/play/playground/tooling/mobile-support.ts"},{"path":"/zh/play/playground/tooling/sharable-urls.ts"},{"path":"/zh/play/playground/tooling/typescript-versions.ts"},{"path":"/zh/play/typescript/language/soundness.ts"},{"path":"/zh/play/typescript/language/structural-typing.ts"},{"path":"/zh/play/typescript/language/type-guards.ts"},{"path":"/zh/play/typescript/language/type-widening-and-narrowing.ts"},{"path":"/zh/play/typescript/language-extensions/enums.ts"},{"path":"/zh/play/typescript/language-extensions/nominal-typing.ts"},{"path":"/zh/play/typescript/language-extensions/types-vs-interfaces.ts"},{"path":"/zh/play/typescript/meta-types/conditional-types.ts"},{"path":"/zh/play/typescript/meta-types/discriminate-types.ts"},{"path":"/zh/play/typescript/meta-types/indexed-types.ts"},{"path":"/zh/play/typescript/meta-types/mapped-types.ts"},{"path":"/zh/play/typescript/primitives/any.ts"},{"path":"/zh/play/typescript/primitives/literals.ts"},{"path":"/zh/play/typescript/primitives/union-and-intersection-types.ts"},{"path":"/zh/play/typescript/primitives/unknown-and-never.ts"},{"path":"/zh/play/typescript/type-primitives/built-in-utility-types.ts"},{"path":"/zh/play/typescript/type-primitives/nullable-types.ts"},{"path":"/zh/play/typescript/type-primitives/tuples.ts"},{"path":"/zh/play/javascript/modern-javascript/immutability.ts"},{"path":"/zh/play/javascript/modern-javascript/async-await.ts"},{"path":"/zh/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/community"},{"path":"/es/community"},{"path":"/ja/community"},{"path":"/vo/community"},{"path":"/zh/community"},{"path":"/download"},{"path":"/es/download"},{"path":"/ja/download"},{"path":"/vo/download"},{"path":"/zh/download"},{"path":"/empty"},{"path":"/es/empty"},{"path":"/ja/empty"},{"path":"/vo/empty"},{"path":"/zh/empty"},{"path":"/"},{"path":"/es/"},{"path":"/ja/"},{"path":"/vo/"},{"path":"/zh/"},{"path":"/tools"},{"path":"/es/tools"},{"path":"/ja/tools"},{"path":"/vo/tools"},{"path":"/zh/tools"},{"path":"/why-create-typescript"},{"path":"/es/why-create-typescript"},{"path":"/ja/why-create-typescript"},{"path":"/vo/why-create-typescript"},{"path":"/zh/why-create-typescript"},{"path":"/docs/home"},{"path":"/es/docs/home"},{"path":"/ja/docs/home"},{"path":"/vo/docs/home"},{"path":"/zh/docs/home"},{"path":"/dev/playground-plugins/"},{"path":"/dev/sandbox/"},{"path":"/dev/twoslash/"},{"path":"/dev/typescript-vfs/"}]},"markdownRemark":{"id":"e6a1d6d3-5ef4-59f5-a8d0-8c5d6fff6188","excerpt":"Stricter Generators TypeScript 3.6 introduces stricter checking for iterators and generator functions.\nIn earlier versions, users of generators had no way to…","html":"<h2 id=\"stricter-generators\" style=\"position:relative;\"><a href=\"#stricter-generators\" aria-label=\"stricter generators permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Stricter Generators</h2>\n<p>TypeScript 3.6 introduces stricter checking for iterators and generator functions.\nIn earlier versions, users of generators had no way to differentiate whether a value was yielded or returned from a generator.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function*</span><span style=\"color: #000000\"> foo() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (Math.random() &lt; </span><span style=\"color: #09835A\">0.5</span><span style=\"color: #000000\">) </span><span style=\"color: #0000FF\">yield</span><span style=\"color: #000000\"> </span><span style=\"color: #09835A\">100</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"Finished!\"</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> iter = foo();</span>\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> curr = iter.next();</span>\n<span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (curr.done) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// TypeScript 3.5 and prior thought this was a 'string | number'.</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// It should know it's 'string' since 'done' was 'true'!</span>\n<span style=\"color: #000000\">    curr.value</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Additionally, generators just assumed the type of <code>yield</code> was always <code>any</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function*</span><span style=\"color: #000000\"> bar() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: { hello(): void } = yield;</span>\n<span style=\"color: #000000\">    x.hello();</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> iter = bar();</span>\n<span style=\"color: #000000\">iter.next();</span>\n<span style=\"color: #000000\">iter.next(</span><span style=\"color: #09835A\">123</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// oops! runtime error!</span></code></div></pre>\n<p>In TypeScript 3.6, the checker now knows that the correct type for <code>curr.value</code> should be <code>string</code> in our first example, and will correctly error on our call to <code>next()</code> in our last example.\nThis is thanks to some changes in the <code>Iterator</code> and <code>IteratorResult</code> type declarations to include a few new type parameters, and to a new type that TypeScript uses to represent generators called the <code>Generator</code> type.</p>\n<p>The <code>Iterator</code> type now allows users to specify the yielded type, the returned type, and the type that <code>next</code> can accept.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Iterator&lt;T, TReturn = any, TNext = undefined&gt; {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// Takes either 0 or 1 arguments - doesn't accept 'undefined'</span>\n<span style=\"color: #000000\">    next(...args: [] | [TNext]): IteratorResult&lt;T, TReturn&gt;;</span>\n<span style=\"color: #000000\">    return?(value?: TReturn): IteratorResult&lt;T, TReturn&gt;;</span>\n<span style=\"color: #000000\">    throw?(e?: any): IteratorResult&lt;T, TReturn&gt;;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Building on that work, the new <code>Generator</code> type is an <code>Iterator</code> that always has both the <code>return</code> and <code>throw</code> methods present, and is also iterable.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Generator&lt;T = unknown, TReturn = any, TNext = unknown&gt;</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> Iterator&lt;T, TReturn, TNext&gt; {</span>\n<span style=\"color: #000000\">    next(...args: [] | [TNext]): IteratorResult&lt;T, TReturn&gt;;</span>\n<span style=\"color: #000000\">    return(value: TReturn): IteratorResult&lt;T, TReturn&gt;;</span>\n<span style=\"color: #000000\">    throw(e: any): IteratorResult&lt;T, TReturn&gt;;</span>\n<span style=\"color: #000000\">    [Symbol.iterator](): Generator&lt;T, TReturn, TNext&gt;;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>To allow differentiation between returned values and yielded values, TypeScript 3.6 converts the <code>IteratorResult</code> type to a discriminated union type:</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\"> IteratorResult&lt;T, TReturn = any&gt; = IteratorYieldResult&lt;T&gt; | IteratorReturnResult&lt;TReturn&gt;;</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> IteratorYieldResult&lt;TYield&gt; {</span>\n<span style=\"color: #000000\">    done?: false;</span>\n<span style=\"color: #000000\">    value: TYield;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> IteratorReturnResult&lt;TReturn&gt; {</span>\n<span style=\"color: #000000\">    done: true;</span>\n<span style=\"color: #000000\">    value: TReturn;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>In short, what this means is that you’ll be able to appropriately narrow down values from iterators when dealing with them directly.</p>\n<p>To correctly represent the types that can be passed in to a generator from calls to <code>next()</code>, TypeScript 3.6 also infers certain uses of <code>yield</code> within the body of a generator function.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function*</span><span style=\"color: #000000\"> foo() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x: string = yield;</span>\n<span style=\"color: #000000\">    console.log(x.toUpperCase());</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> x = foo();</span>\n<span style=\"color: #000000\">x.next(); </span><span style=\"color: #008000\">// first call to 'next' is always ignored</span>\n<span style=\"color: #000000\">x.next(</span><span style=\"color: #09835A\">42</span><span style=\"color: #000000\">); </span><span style=\"color: #008000\">// error! 'number' is not assignable to 'string'</span></code></div></pre>\n<p>If you’d prefer to be explicit, you can also enforce the type of values that can be returned, yielded, and evaluated from <code>yield</code> expressions using an explicit return type.\nBelow, <code>next()</code> can only be called with <code>boolean</code>s, and depending on the value of <code>done</code>, <code>value</code> is either a <code>string</code> or a <code>number</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">/**</span>\n<span style=\"color: #008000\"> * - yields numbers</span>\n<span style=\"color: #008000\"> * - returns strings</span>\n<span style=\"color: #008000\"> * - can be passed in booleans</span>\n<span style=\"color: #008000\"> */</span>\n<span style=\"color: #0000FF\">function*</span><span style=\"color: #000000\"> counter(): Generator&lt;number, string, boolean&gt; {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> i = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">while</span><span style=\"color: #000000\"> (</span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">) {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">if</span><span style=\"color: #000000\"> (yield i++) {</span>\n<span style=\"color: #000000\">            </span><span style=\"color: #0000FF\">break</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">        }</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"done!\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> iter = counter();</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> curr = iter.next()</span>\n<span style=\"color: #0000FF\">while</span><span style=\"color: #000000\"> (!curr.done) {</span>\n<span style=\"color: #000000\">    console.log(curr.value);</span>\n<span style=\"color: #000000\">    curr = iter.next(curr.value === </span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">)</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #000000\">console.log(curr.value.toUpperCase());</span>\n\n<span style=\"color: #008000\">// prints:</span>\n<span style=\"color: #008000\">//</span>\n<span style=\"color: #008000\">// 0</span>\n<span style=\"color: #008000\">// 1</span>\n<span style=\"color: #008000\">// 2</span>\n<span style=\"color: #008000\">// 3</span>\n<span style=\"color: #008000\">// 4</span>\n<span style=\"color: #008000\">// 5</span>\n<span style=\"color: #008000\">// DONE!</span></code></div></pre>\n<p>For more details on the change, <a href=\"https://github.com/Microsoft/TypeScript/issues/2983\">see the pull request here</a>.</p>\n<h2 id=\"more-accurate-array-spread\" style=\"position:relative;\"><a href=\"#more-accurate-array-spread\" aria-label=\"more accurate array spread 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>More Accurate Array Spread</h2>\n<p>In pre-ES2015 targets, the most faithful emit for constructs like <code>for</code>/<code>of</code> loops and array spreads can be a bit heavy.\nFor this reason, TypeScript uses a simpler emit by default that only supports array types, and supports iterating on other types using the <code>--downlevelIteration</code> flag.\nThe looser default without <code>--downlevelIteration</code> works fairly well; however, there were some common cases where the transformation of array spreads had observable differences.\nFor example, the following array containing a spread</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #000000\">[...Array(</span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">)]</span></code></div></pre>\n<p>can be rewritten as the following array literal</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #000000\">[</span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">undefined</span><span style=\"color: #000000\">]</span></code></div></pre>\n<p>However, TypeScript would instead transform the original code into this code:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #000000\">Array(</span><span style=\"color: #09835A\">5</span><span style=\"color: #000000\">).slice();</span></code></div></pre>\n<p>which is slightly different.\n<code>Array(5)</code> produces an array with a length of 5, but with no defined property slots.</p>\n<p>TypeScript 3.6 introduces a new <code>__spreadArrays</code> helper to accurately model what happens in ECMAScript 2015 in older targets outside of <code>--downlevelIteration</code>.\n<code>__spreadArrays</code> is also available in <a href=\"https://github.com/Microsoft/tslib/\">tslib</a>.</p>\n<p>For more information, <a href=\"https://github.com/microsoft/TypeScript/pull/31166\">see the relevant pull request</a>.</p>\n<h2 id=\"improved-ux-around-promises\" style=\"position:relative;\"><a href=\"#improved-ux-around-promises\" aria-label=\"improved ux around promises 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>Improved UX Around Promises</h2>\n<p>TypeScript 3.6 introduces some improvements for when <code>Promise</code>s are mis-handled.</p>\n<p>For example, it’s often very common to forget to <code>.then()</code> or <code>await</code> the contents of a <code>Promise</code> before passing it to another function.\nTypeScript’s error messages are now specialized, and inform the user that perhaps they should consider using the <code>await</code> keyword.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> User {</span>\n<span style=\"color: #000000\">    name: string;</span>\n<span style=\"color: #000000\">    age: number;</span>\n<span style=\"color: #000000\">    location: string;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> getUserData(): Promise&lt;User&gt;;</span>\n<span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> displayUser(user: User): void;</span>\n\n<span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> f() {</span>\n<span style=\"color: #000000\">    displayUser(getUserData());</span>\n<span style=\"color: #008000\">//              ~~~~~~~~~~~~~</span>\n<span style=\"color: #008000\">// Argument of type 'Promise&lt;User&gt;' is not assignable to parameter of type 'User'.</span>\n<span style=\"color: #008000\">//   ...</span>\n<span style=\"color: #008000\">// Did you forget to use 'await'?</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>It’s also common to try to access a method before <code>await</code>-ing or <code>.then()</code>-ing a <code>Promise</code>.\nThis is another example, among many others, where we’re able to do better.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">async</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> getCuteAnimals() {</span>\n<span style=\"color: #000000\">    fetch(</span><span style=\"color: #A31515\">\"https://reddit.com/r/aww.json\"</span><span style=\"color: #000000\">)</span>\n<span style=\"color: #000000\">        .json()</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">//   ~~~~</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// Property 'json' does not exist on type 'Promise&lt;Response&gt;'.</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">//</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// Did you forget to use 'await'?</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>For more details, <a href=\"https://github.com/microsoft/TypeScript/issues/30646\">see the originating issue</a>, as well as the pull requests that link back to it.</p>\n<h2 id=\"better-unicode-support-for-identifiers\" style=\"position:relative;\"><a href=\"#better-unicode-support-for-identifiers\" aria-label=\"better unicode support for identifiers permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Better Unicode Support for Identifiers</h2>\n<p>TypeScript 3.6 contains better support for Unicode characters in identifiers when emitting to ES2015 and later targets.</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\"> 𝓱𝓮𝓵𝓵𝓸 = </span><span style=\"color: #A31515\">\"world\"</span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// previously disallowed, now allowed in '--target es2015'</span></code></div></pre>\n<h2 id=\"importmeta-support-in-systemjs\" style=\"position:relative;\"><a href=\"#importmeta-support-in-systemjs\" aria-label=\"importmeta support in systemjs 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>import.meta</code> Support in SystemJS</h2>\n<p>TypeScript 3.6 supports transforming <code>import.meta</code> to <code>context.meta</code> when your <code>module</code> target is set to <code>system</code>.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// This module:</span>\n\n<span style=\"color: #000000\">console.log(import.meta.url)</span>\n\n<span style=\"color: #008000\">// gets turned into the following:</span>\n\n<span style=\"color: #000000\">System.register([], </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> (exports, context) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    setters: [],</span>\n<span style=\"color: #000000\">    execute: </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> () {</span>\n<span style=\"color: #000000\">      console.log(context.meta.url);</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">  };</span>\n<span style=\"color: #000000\">});</span></code></div></pre>\n<h2 id=\"get-and-set-accessors-are-allowed-in-ambient-contexts\" style=\"position:relative;\"><a href=\"#get-and-set-accessors-are-allowed-in-ambient-contexts\" aria-label=\"get and set accessors are allowed in ambient contexts 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>get</code> and <code>set</code> Accessors Are Allowed in Ambient Contexts</h2>\n<p>In previous versions of TypeScript, the language didn’t allow <code>get</code> and <code>set</code> accessors in ambient contexts (like in <code>declare</code>-d classes, or in <code>.d.ts</code> files in general).\nThe rationale was that accessors weren’t distinct from properties as far as writing and reading to these properties;\nhowever, <a href=\"https://github.com/tc39/proposal-class-fields/issues/248\">because ECMAScript’s class fields proposal may have differing behavior from in existing versions of TypeScript</a>, we realized we needed a way to communicate this different behavior to provide appropriate errors in subclasses.</p>\n<p>As a result, users can write getters and setters in ambient contexts in TypeScript 3.6.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Foo {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// Allowed in 3.6+.</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">get</span><span style=\"color: #000000\"> x(): number;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">set</span><span style=\"color: #000000\"> x(val: number): void;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>In TypeScript 3.7, the compiler itself will take advantage of this feature so that generated <code>.d.ts</code> files will also emit <code>get</code>/<code>set</code> accessors.</p>\n<h2 id=\"ambient-classes-and-functions-can-merge\" style=\"position:relative;\"><a href=\"#ambient-classes-and-functions-can-merge\" aria-label=\"ambient classes and functions can merge 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>Ambient Classes and Functions Can Merge</h2>\n<p>In previous versions of TypeScript, it was an error to merge classes and functions under any circumstances.\nNow, ambient classes and functions (classes/functions with the <code>declare</code> modifier, or in <code>.d.ts</code> files) can merge.\nThis means that now you can write the following:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> Point2D(x: number, y: number): Point2D;</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> Point2D {</span>\n<span style=\"color: #000000\">    x: number;</span>\n<span style=\"color: #000000\">    y: number;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(x: number, y: number);</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>instead of needing to use </p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> Point2D {</span>\n<span style=\"color: #000000\">    x: number;</span>\n<span style=\"color: #000000\">    y: number;</span>\n<span style=\"color: #000000\">}</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">declare</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> Point2D: {</span>\n<span style=\"color: #000000\">    (x: number, y: number): Point2D;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> (x: number, y: number): Point2D;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>One advantage of this is that the callable constructor pattern can be easily expressed while also allowing namespaces to merge with these declarations (since <code>var</code> declarations can’t merge with <code>namespace</code>s).</p>\n<p>In TypeScript 3.7, the compiler will take advantage of this feature so that <code>.d.ts</code> files generated from <code>.js</code> files can appropriately capture both the callability and constructability of a class-like function.</p>\n<p>For more details, <a href=\"https://github.com/microsoft/TypeScript/pull/32584\">see the original PR on GitHub</a>.</p>\n<h2 id=\"apis-to-support---build-and---incremental\" style=\"position:relative;\"><a href=\"#apis-to-support---build-and---incremental\" aria-label=\"apis to support   build and   incremental 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>APIs to Support <code>--build</code> and <code>--incremental</code></h2>\n<p>TypeScript 3.0 introduced support for referencing other and building them incrementally using the <code>--build</code> flag.\nAdditionally, TypeScript 3.4 introduced the <code>--incremental</code> flag for saving information about previous compilations to only rebuild certain files.\nThese flags were incredibly useful for structuring projects more flexibly and speeding builds up.\nUnfortunately, using these flags didn’t work with 3rd party build tools like Gulp and Webpack.\nTypeScript 3.6 now exposes two sets of APIs to operate on project references and incremental program building.</p>\n<p>For creating <code>--incremental</code> builds, users can leverage the <code>createIncrementalProgram</code> and <code>createIncrementalCompilerHost</code> APIs.\nUsers can also re-hydrate old program instances from <code>.tsbuildinfo</code> files generated by this API using the newly exposed <code>readBuilderProgram</code> function, which is only meant to be used as for creating new programs (i.e. you can’t modify the returned instance - it’s only meant to be used for the <code>oldProgram</code> parameter in other <code>create*Program</code> functions).</p>\n<p>For leveraging project references, a new <code>createSolutionBuilder</code> function has been exposed, which returns an instance of the new type <code>SolutionBuilder</code>.</p>\n<p>For more details on these APIs, you can <a href=\"https://github.com/microsoft/TypeScript/pull/31432\">see the original pull request</a>.</p>\n<h2 id=\"semicolon-aware-code-edits\" style=\"position:relative;\"><a href=\"#semicolon-aware-code-edits\" aria-label=\"semicolon aware code edits 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>Semicolon-Aware Code Edits</h2>\n<p>Editors like Visual Studio and Visual Studio Code can automatically apply quick fixes, refactorings, and other transformations like automatically importing values from other modules.\nThese transformations are powered by TypeScript, and older versions of TypeScript unconditionally added semicolons to the end of every statement; unfortunately, this disagreed with many users’ style guidelines, and many users were displeased with the editor inserting semicolons.</p>\n<p>TypeScript is now smart enough to detect whether your file uses semicolons when applying these sorts of edits.\nIf your file generally lacks semicolons, TypeScript won’t add one.</p>\n<p>For more details, <a href=\"https://github.com/microsoft/TypeScript/pull/31801\">see the corresponding pull request</a>.</p>\n<h2 id=\"smarter-auto-import-syntax\" style=\"position:relative;\"><a href=\"#smarter-auto-import-syntax\" aria-label=\"smarter auto import syntax 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>Smarter Auto-Import Syntax</h2>\n<p>JavaScript has a lot of different module syntaxes or conventions: the one in the ECMAScript standard, the one Node already supports (CommonJS), AMD, System.js, and more!\nFor the most part, TypeScript would default to auto-importing using ECMAScript module syntax, which was often inappropriate in certain TypeScript projects with different compiler settings, or in Node projects with plain JavaScript and <code>require</code> calls.</p>\n<p>TypeScript 3.6 is now a bit smarter about looking at your existing imports before deciding on how to auto-import other modules.\nYou can <a href=\"https://github.com/microsoft/TypeScript/pull/32684\">see more details in the original pull request here</a>.</p>\n<h2 id=\"await-completions-on-promises\" style=\"position:relative;\"><a href=\"#await-completions-on-promises\" aria-label=\"await completions on promises 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>await</code> Completions on Promises</h2>\n<p>In TypeScript 3.6, completions on an </p>\n<h2 id=\"new-typescript-playground\" style=\"position:relative;\"><a href=\"#new-typescript-playground\" aria-label=\"new typescript playground 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 TypeScript Playground</h2>\n<p>The TypeScript playground has received a much-needed refresh with handy new functionality!\nThe new playground is largely a fork of <a href=\"https://github.com/agentcooper\">Artem Tyurin</a>’s <a href=\"https://github.com/agentcooper/typescript-play\">TypeScript playground</a> which community members have been using more and more.\nWe owe Artem a big thanks for helping out here!</p>\n<p>The new playground now supports many new options including:</p>\n<ul>\n<li>The <code>target</code> option (allowing users to switch out of <code>es5</code> to <code>es3</code>, <code>es2015</code>, <code>esnext</code>, etc.)</li>\n<li>All the strictness flags (including just <code>strict</code>)</li>\n<li>Support for plain JavaScript files (using <code>allowJS</code> and optionally <code>checkJs</code>)</li>\n</ul>\n<p>These options also persist when sharing links to playground samples, allowing users to more reliably share examples without having to tell the recipient “oh, don’t forget to turn on the <code>noImplicitAny</code> option!“.</p>\n<p>In the near future, we’re going to be refreshing the playground samples, adding JSX support, and polishing automatic type acquisition, meaning that you’ll be able to see the same experience on the playground as you’d get in your personal editor.</p>\n<p>As we improve the playground and the website, <a href=\"https://github.com/microsoft/TypeScript-Website/\">we welcome feedback and pull requests on GitHub</a>!</p>","headings":[{"value":"Stricter Generators","depth":2},{"value":"More Accurate Array Spread","depth":2},{"value":"Improved UX Around Promises","depth":2},{"value":"Better Unicode Support for Identifiers","depth":2},{"value":"import.meta Support in SystemJS","depth":2},{"value":"get and set Accessors Are Allowed in Ambient Contexts","depth":2},{"value":"Ambient Classes and Functions Can Merge","depth":2},{"value":"APIs to Support --build and --incremental","depth":2},{"value":"Semicolon-Aware Code Edits","depth":2},{"value":"Smarter Auto-Import Syntax","depth":2},{"value":"await Completions on Promises","depth":2},{"value":"New TypeScript Playground","depth":2}],"frontmatter":{"permalink":"/docs/handbook/release-notes/typescript-3-6.html","title":"TypeScript 3.6"}}},"pageContext":{"slug":"/docs/handbook/release-notes/typescript-3-6.html","isOldHandbook":true}}}