Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon

TypeScript 3.6 releases with stricter generators, new functions in TypeScript playground, better Unicode support for identifiers, and more

Save for later
  • 4 min read
  • 29 Aug 2019

article-image

Yesterday, the Program Manager at Typescript, Daniel Rosenwasser announced the release of TypeScript 3.6. This is a major release of TypeScript as it contains many new features in Language and Compiler such as stricter generators, more accurate array spread, improved UX around Promises, better Unicode support for identifiers, and more. TypeScript 3.6 also explores a new TypeScript playground, new Editor features, and many breaking changes.

TypeScript 3.6 beta was released last month.

Language and Compiler improvements

Stricter checking to Iterators and Generators


Previously, generator users in TypeScript could not differentiate if a value was yielded or returned from a generator. In TypeScript 3.6, due to changes in the Iterator and IteratorResult type declarations, a new type called the Generator type has been introduced. It is an Iterator that will have both the return and throw methods present. This will allow a stricter generator checker to easily understand the difference between the values from their iterators.

TypeScript 3.6 also infers certain uses of yield within the body of a generator function. The yield expression can be used explicitly to enforce the type of values that can be returned, yielded, and evaluated.

More accurate array spread


In pre-ES2015 targets, TypeScript uses a by default --downlevelIteration flag to use iterative constructs with arrays. However, many users found it undesirable that emits produced by it had no defined property slots. To address this problem, TypeScript 3.6 presents a new __spreadArrays helper. It will “accurately model what happens in ECMAScript 2015 in older targets outside of --downlevelIteration.”

Improved UX around Promises


TypeScript 3.6 explores new improvements in the Promise API, which is one of the most common ways to work with asynchronous data. TypeScript’s error messages will now inform the user if a then() or await content of a Promise API is not written before passing it to another function. The Promise API will also provide quick fixes in some cases.

Better Unicode support for Identifiers


TypeScript 3.6 contains better support for Unicode characters in identifiers when emitting to ES2015 and later targets.

import.meta support in SystemJS: The new version supports the transformation of import.meta to context.meta when the module target is set to system.

get and set accessors are allowed in ambient contexts: The previous versions of TypeScript did not allow the use of get and set accessors in ambient contexts. This feature has been changed in TypeScript 3.6, since the ECMAScript’s class fields proposal have differing behavior from an existing version of TypeScript. The official post also adds, “In TypeScript 3.7, the compiler itself will take advantage of this feature so that generated .d.ts files will also emit get/set accessors.”

Read Also: Microsoft introduces Pyright, a static type checker for the Python language written in TypeScript

New functions in TypeScript playground


The TypeScript playground allows users to compile TypeScript and check the JavaScript output. It has more compiler options than typescriptlang and all the strict options are turned on by default in the playground.

Following new functions are added in TypeScript Playground:

  • The target option which allows users to switch out of es5 to es3, es2015, esnext, etc
  • All the strictness flags
  • Unlock access to the largest independent learning library in Tech for FREE!
    Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
    Renews at €18.99/month. Cancel anytime
  • Support for plain JavaScript files


The post also states that in the future versions of TypeScript, more features like JSX support, and polishing automatic type acquisition can be expected.

Breaking Changes

  • Class members named "constructor" are now simply constructor functions.
  • DOM updates like the global window will no longer be defined as type Window. Instead, it is defined as type Window & typeof globalThis.
  • In JavaScript files, TypeScript will only consult immediately preceding JSDoc comments to figure out declared types.
  • TypeScript 3.6 will not allow the escape sequences.


Developers have liked the new features in TypeScript 3.6.

https://twitter.com/zachcodes/status/1166840093849473024

https://twitter.com/joshghent/status/1167005999204638722

https://twitter.com/FlorianRappl/status/1166842492718899200

Interested users can check out TypeScript’s 6-month roadmap. Visit the Microsoft blog for full updates of TypeScript 3.6.

Next.js 9 releases with built in zero-config TypeScript support, automatic static optimization, API routes and more

Babel 7.5.0 releases with F# pipeline operator, experimental TypeScript namespaces support, and more

TypeScript 3.5 releases with ‘omit’ helper, improved speed, excess property checks and more