TypeScript 2.0 beta kicks async support down the road

There's still a lot to like in the newest version of Microsoft's JavaScript-derived language, like non-nullable variable types

TypeScript 2.0 beta kicks async support down the road

The first beta of TypeScript 2.0, the latest version of Microsoft's "industrial-strength JavaScript," was announced earlier this week.

The bad news: It doesn't deliver everything promised for 2.0. It does, however, provide a slew of new features for type-checking -- long regarded as the biggest benefit TypeScript provides for JavaScript programmers.

One of the big additions promised for 2.0 --  non-nullable types -- is being delivered. Pass a flag to TypeScript and it will ensure that, for instance, strings or numbers never end up being assigned to null or undefined. In cases where you want something to be given those values, null and undefined are now available as types.

In cases where you want to override the type system's protections, Microsoft allows a way to conditionally override it. Add "!" as a postfix to any variable (such as user_name!), and TypeScript will assume the variable in question doesn't need to be guarded against null/undefined checks.

Not all of 2.0's additions revolve around types; some deal with the workflow around a script. Module declarations, for example, are easier to write this time around. A developer in a hurry can start with a stub declaration that has no actual code in it or even declare a whole package of modules in this fashion.

What's missing from 2.0 -- for now -- is support for async/await. These keywords were introduced in ECMAScript 2016 to make asynchronous programming easier, in the same manner as similar keywords for C#, Dart, and Python. One boon is that TypeScript code written with async/await can be compiled down to versions of JavaScript (EC5, for instance) that don't support those keywords.

Microsoft's beta notes indicate that the main reason for the delay in support was to make sure TypeScript could generate the needed async/await code quickly enough, and to thoroughly test the resulting behaviors. "While we feel confident in today's implementation, confidence is no match for thorough testing," Microsoft wrote.

As a result, async/await support has been bumped to the 2.1 release.

Copyright © 2016 IDG Communications, Inc.