BT

Microsoft Bumps TypeScript to Version 1.7

| by David Iffland Follow 4 Followers on Dec 08, 2015. Estimated reading time: 1 minute |

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 Stage
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.

Tell us what you think

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

Email me replies to any of my messages in this thread

Typescript is good, but Dart is still better by Andrew Mezoni

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

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

Email me replies to any of my messages in this thread

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

Email me replies to any of my messages in this thread

2 Discuss
BT