Greetings, colleagues! Yesterday, Microsoft stiffened and rolled out the release of the next version of typescript, a typed add-on over javascript. In the new version, not only exponentiation and separate configuration of targets, but also the first developments in
async /
await from the ES7 standard. More under the cut.
async / await, but not for all
The main feature that has been tested in beta for a long time is support for the
async and
await keywords for working with promises at the language level. This syntax is developed within the framework of the following standard ES7: one of the features of Typescript is that it drags language features not only from ES6, but also from ES7. Unfortunately, the current version typescript can generate
async and
await code only for js interpreters with generator support. While from such node.js of the fourth version. The authors promise to make support for Bauser / ES5, but complain that such an implementation requires the code generator to create a state machine, which greatly complicates the entire compilation process.
"use strict";
Polymorphic this
Now for the return value of the function, you can specify
this . This means - “an object of this class or any class inherited from it”. It is very convenient to create a “fluent api” when the method returns an object of a previously unknown type:
')
interface Model { setupBase(): this; } interface AdvancedModel extends Model { setupAdvanced(): this; } declare function createModel(): AdvancedModel; newModel = newModel.setupBase().setupAdvanced(); // fluent style works
--module now supports ES6
Starting from this version, it is possible to more flexibly configure in which javascript to compile and for which system of work with modules. For example, you can collect ES6 code, but with commonjs modules, for nodes:
ES7 Exponentiation
A small syntax sugar from ES7, which came to replace
Math.pow :
let squared = 2 ** 2;
Where to get?
The latest version typescript is traditionally available on the
official website and in npm:
npm update typescript