Paul Krill
Editor at Large

Microsoft’s TypeScript 2.0 is due by June

news
Apr 6, 20162 mins

The non-nullable type is the key new feature in Microsoft’s JavaScript superset

closeup of retro typewriter key with the letter B for blog
Credit: Thinkstock

TypeScript 2.0, the next major version of Microsoft’s typed superset of JavaScript, is due by June and will feature non-nullable types.

Among the most requested feature for TypeScript, non-nullable types use a compiler switch called strict null checks, said Anders Hejlsberg, a Microsoft technical fellow and developer of TypeScript. “In strict null checks, we say undefined and null are no longer part of all of the types.” A number is a number, a string is a string, and a Boolean is only true or false; it cannot be null or undefined.

As a result of this changes, TypeScript 2.0 will add two new types. One has a single possible value, undefined; the other new type is called null. Union types can be used to join them. “If you want to have a thing that can be number or undefined, you write it as a union type,” Hejlsberg said.

Non-nullable and control flow-based types planned for TypeScript feature definite assignment analysis and control flow reflected in the types of local variables. Improved typing acquisitions, meanwhile, use NPM to install type declaration packages. Microsoft chose NPM because it already serves as JavaScript’s package manager, Hejlsberg said. NPM can be used to manage dependencies between these declarations.

Other features planned for TypeScript 2.0 include read-only properties and async/await downlevel support. Async/await in TypeScript has enabled asynchronous code flows written as if they were synchronous, removing the need for event handlers or specific callback functions; in November 2015, Microsoft said async/await could be used only by developers targeting Node.js 4 or later.

Hejlsberg also briefly described plans for TypeScript 2.1 and beyond. Features envisioned for these releases include a new JavaScript language service in Microsoft’s Visual Studio software development platform and more refactoring support.

The most recent version, TypeScript 1.8, rolled out in February, with quicker compilation and module augmentation.

JavaScript was not engineered for writing large apps, but is now regularly used for the task, Hejlsberg said, which is why TypeScript was created. Built to make JavaScript scale, TypeScript compiles to JavaScript and is used in development of JavaScript frameworks such as Angular and the Dojo Toolkit, he noted. “It’s about making it easier to build medium to large apps in JavaScript.”

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author