TypeScript 2.3 gets smarter about JavaScript standards

Ngoc Huynh

Now at a release candidate stage, the latest version of Microsoft’s typed JavaScript superset supports async generators and iterators.

TypeScript 2.3, the latest version of Microsoft’s typed superset of JavaScript, has moved to a release candidate stage.

For standards backing, version 2.3 supports async generators and iterators. “Async iterators are an upcoming ECMAScript feature that allows iterators to produce results asynchronously,” Daniel Rosenwasser, Microsoft program manager for TypeScript, said. Async generators, meanwhile, can await at any point.

TypeScript 2.3 also offers down-level iterator and generator support. Previously, generators were not supported when targeting ECMAScript versions 3 or 5. “The new –downlevelIteration flag gives users a model where emit can stay simple for most users, and those in need of general iterator and generator support can opt in,” said Rosenwasser. TypeScript 2.3 thus makes it easier to use libraries like redux-saga, where support for generators is expected.

To address issues with strictness in TypeScript’s type system, version 2.3 introduces a –strict flag to implicitly enable common strictness options. “If you ever need to opt out, you can explicitly turn these options off yourself,” said Rosenwasser. The language has options for different levels of strictness, and it’s common to begin at the strictest settings so the language can provide the best experience, but the compiler has grown a lot of different options, such as –strictNullChecks and –noImplicitThis. “Unfortunately if you can’t remember these, it just makes TypeScript harder to use,” Rosenwasser admitted. Future plans call for possibly including other strict checks that could be manually toggled off.

TypeScript 2.3 is due to add other capabilities as well, such as error reporting in all .js files and language service extensibility, and a full release of version 2.3 is due later this month. Accessible via NuGet or npm, TypeScript 2.3 can work with Visual Studio 2015 IDE, with Microsoft planning to extend support to the newly released Visual Studio 2017 as well. TypeScript compiles to plain JavaScript while supporting practices such as code refactoring, and it gained some notoriety recently when Google’s Angular JavaScript framework was rewritten in it.

Share the news now

Source : http://www.infoworld.com