React, etc. Tech Stack

React, Flux, GraphQL, Hack, HHVM...? All of this and more!

Async/Await support for ES5 browsers pushed to TypeScript 2.1

Today Microsoft announced the first 2.0 beta of their Open Source TypeScript language. Many were awaiting for the first major revision of the language to include Async/Await - an excellent asynchronous pattern loved by .NET developers.

At the end of the blog post announcing TypeScript 2.0 beta, the company reveals that Async/Await for ES5 compatible browsers is coming in TypeScript 2.1. It has proved to be a tough nut to crack, even for the bright minds working working on the Language:

One feature you might be wondering about is support for async functions in ES3 & ES5. Originally, this was slated for the 2.0 release; however, to reasonably implement async/await, we needed to rewrite TypeScript’s emitter as a series of tree transformations. Doing so, while keeping TypeScript fast, has required a lot of work and attention to detail.

ES5 is the version of JavaScript currently widely supported in browsers and the Node.js serverside JavaScript platform. TypeScript has been able to target Async/Await for ES6 compatible runtimes since TypeScript 1.7. But since a majority of browsers still don't support ES6 - the technology has been not available for large masses of users.

Microsoft promises to bring this feature for browsers supporting ES5 later in TypeScript 2.1, which is already under works and there is a pull request open on GitHub which users can track to follow progress.

For eager adopters of Async/Await in TypeScript, all major browsers are moving forward with native ES6 level support that is already able to support the JavaScript compilations that is done from TypeScript 1.7-> to ECMAScript 6 targets.

If you're targeting conservative users or want the largest possible audience, you'll need to wait for TypeScript 2.1, but time is your friend as ES6 compatible browsers are becoming more common each month.

For some interesting background on TypeScript 2, you should watch the video below where Anders Hejlsberg gives some perspective to what is going on behind the scenes: