BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Microsoft Bumps TypeScript to Version 1.7

Microsoft Bumps TypeScript to Version 1.7

Microsoft has released version 1.7 of TypeScript, their JavaScript superset language. The newest version fulfills some promises and makes certain scenarios easier to code.

One of the most anticipated features, async/await, is now available for those targeting ES6. Async/await allows developers to mark a function as async. Using an asynchronous function along with the await keyword allows developers to work with a function in a synchronous manner even though it's not. Right now, it's only usable for ES6 because it uses generators behind the scenes.

Due to the complexity of the feature, it's not expected to be available for ES5 targets until version 2.0. In a separate post, Microsoft said it's a big change:

To target the breadth of browsers, we need to rewrite ES6 generator functions into ES5-executable JavaScript using a state machine. It’s a big challenge that requires significant changes across the compiler, but we’re working on it.

Developers who wish to use the feature today across all browsers can use Babel.

Microsoft also added a polymorphic this type, which makes it easier to write fluent style code such as:

var result = myObject.doSomething().doSomethingElse();

In their words, "A this type can be used in classes and interfaces to represent some type that is a subtype of the containing type (rather than the containing type itself)." For a clear example of what the feature enables, check out the TypeScript Wiki. On a discussion on Hacker News, user tlarkworthy is enthusiastic about the feature:

Polymorphic this is really useful for the 'cannot reference a type twice in the type list' issue you get when doing generics. Since learning it I have used it many times. It's solves many issues like typing a clone method. Awesome addition!

Developers can get TypeScript 1.7 with npm, Visual Studio 2015 Update 1, and Visual Studio 2013.

Rate this Article

Adoption
Style

BT