It's Friday – and that means one thing: Yup, Microsoft's TypeScript 2.0 is out

JavaScript superset adds new features including non-nullable types and read-only properties

Microsoft has released TypeScript 2.0, a major update to its typed version of JavaScript.

TypeScript first appeared in October 2012, and is a project backed by Microsoft’s Anders Heljsberg – the inventor of C# and before that Borland’s Delphi.

The thinking behind the open-source project, which is a superset of JavaScript, is that large, complex applications are easier to code and to maintain in a language which supports static typing, rather than the dynamic typing used by JavaScript. The TypeScript compiler emits standard JavaScript code; no special runtime is required. Version 1.0 was released in April 2014, and since then frequent minor updates have appeared.

TypeScript received a significant boost in March 2015 when the team behind the Google-sponsored Angular project, an open-source web application framework, adopted TypeScript for Angular 2. The release version of Angular 2 was announced on September 15, 2016.

The TypeScript project is hosted on, where it is the 15th most popular language according to the number of Pull Requests, with 250 per cent growth year on year, just behind Apple's Swift language.

The most notable feature in TypeScript 2.0 is non-nullable types. Variables with a value of null are a common source of programming errors, so much so that computer scientist Tony Hoare, who introduced null references in ALGOL W in 1965, described it as his "billion dollar mistake."

JavaScript allows null and undefined variables, as did the first version of TypeScript. If you enable the compiler option strictNullChecks, TypeScript variables become non-nullable by default. The compiler will check both for variables set to null, and for the common problem of variables that are used before a value has been assigned.

It is still possible to have nullable types in TypeScript 2.0, by declaring a variable as a union such as "number or null", expressed as let x: number | null. The TypeScript team also had to set non-nullable types off by default because it is a change that breaks existing code.

Other changes include the ability to define properties as read-only, private and protected class constructors, and a new type called never which is used for values that never occur. The full list of new features are documented here. ®

Other stories you might like

Biting the hand that feeds IT © 1998–2022