Microsoft's TypeScript 1.5 falls in line with ECMAScript

TypeScript, Microsoft's variant of JavaScript, will be upgraded to version 1.5 this week.

Like TypeScript 1.4, the new version emphasizes conformance with the ECMAScript 6 specification, which serves as the basis for JavaScript. Version 1.5 simplifies the use of modules and supports the experimental Decorators function in ES7, for attaching metadata to classes and functions.

TypeScript "provides strong typing so that you get the same productivity that you get from C# in terms of Intellisense, statement completion, and navigation, but with core JavaScript" said Microsoft's Amanda Silver, partner director of program management, during a webcast introducing the Visual Studio 2015 software development platform on Monday. Version 1.5 also can function with Visual Studio 2013 via a separate download.

The focus on ECMAScript features moves TypeScript toward the goal of becoming a superset of ES6 and offering type-checking for the specification's major features, said Microsoft's Jonathan Turner, senior program manager, in an MSDN blog post. "With this release, we've begun supporting the official ES6 modules, we're simplifying how modules work, and we're adding support for more kinds of modules as output."

ES6 modules are separately loaded source files that possibly import other modules as well as provide externally accessible exports, Microsoft explains on GitHub. "ES6 module syntax offers a rich way of working with modules," Turner said. " Similar to external modules in TypeScript, ES6 modules can import modules and exports each piece of your public API. Additionally, ES6 modules allow you to selectively import the parts of that public API you want to use."

With Decorator support, Microsoft is backing a future feature. "Since Decorators are being defined in ES7, which hasn't stabilized yet, the feature is considered 'experimental', but it is already showing how powerful it is when working with rich libraries and applications," Turner said. Microsoft in its blog shows Decorators being used with the Angular2 JavaScript framework. "As you can see [in the blog entry], Angular 2 uses Decorators to define the HTML selector and template on a class directly. We're excited to see what else developers do with this feature."

To make it easier to start using TypeScript, the compiler supports a tsconfig.json file allowing users to specify files in a project and the compiler settings. "This lets you create a lightweight project that can be used both on the command line and within the editor," said Turner.

The road map for TypeScript calls for such capabilities as ES6 Generators, which provide a syntactic way to declare a function that can yield, in TypeScript 1.6. For version 2.0, module bundling and improving lib.d.ts modularity are on the drawing board.

Copyright 2019 IDG Communications. ABN 14 001 592 650. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of IDG Communications is prohibited.