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.”
New functions in TypeScript 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
The post also states that in the future versions of TypeScript, more features like JSX support, and polishing automatic type acquisition can be expected.
- 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.
- TypeScript 3.6 will not allow the escape sequences.
Developers have liked the new features in TypeScript 3.6.
Typescript 3.6 finally fixes the wrong auto import syntax from things like lodash! Yay! pic.twitter.com/CPsSOOSJgI
— Zach Silveira (@zachcodes) August 28, 2019
Great addition in Typescript 3.6 to detect calls to async functions without specifying await. This has been a long-awaited feature 😉https://t.co/boqFa3bEvW
— Josh Ghent (@joshghent) August 29, 2019
— Florian Rappl (@FlorianRappl) August 28, 2019