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

Bookmarks

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

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • Typescript is good, but Dart is still better

    by Andrew Mezoni,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Typescript is good, but Dart is still better.
    Soon will come a time when Typescript will be compiled in the Dart (new lingua franca of the web).

  • Re: Typescript is good, but Dart is still better

    by Dan Mendes,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Andrew, Dart is great there is only one problem for its adoption, its a Google project tightly coupled with Chrome, therefore the Dart run-time is probably "never" going to be adopted by other browser vendors, so the JS run-time does not appear to go anywhere for a long long time. JS is like a cockroach it can stand a nuclear attack!

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT