TypeScript 2.0 Final Version Not To Be Missed

The final point release of Microsoft's JavaScript-like language comes with tagged unions, glob support and new types with which to play around.

It's been a few weeks since Microsoft released its latest version of TypeScript. Near the end of September in fact, the team responsible for its development posted information on the version 2.0 final release, which come with tagged unions, glob support and new types with which to play around.

Microsoft Program Manager Daniel Rosenwasser offered a short history lesson in a blog post on the evoluton of TypeScript: version 1.0, introduced only a few years ago, provided a glimpse into "the potential of JavaScript when combined with static types... and ... compile-time error checking"; 1.1 came with a performance boost and rewritten compiler; 1.4 and 1.5 got cozier with support for ECMAscript versions 2015 and 6.0; and 1.6 and 1.8 provided full support for ES, JavaScript patterns and libraries, and compiler enhancements.

With version 2.0 in beta just a few short months ago, "TypeScript delivers close ECMAScript spec alignment, wide support for JavaScript libraries and tools, and a language service that powers a first class editing experience in all major editors; all of which come together to provide an even more productive and scalable JavaScript development experience," he writes.

New types in this version include null- and undefined-aware types, which, prior to this version, couldn't be explicitly named. "In TypeScript 2.0, null and undefined have their own types which allows developers to explicitly express when null/undefined values are acceptable," writes Rosenwasser. "Now, when something can be either a number or null, you can describe it with the union type number | null (which reads as "number or null")." It's a breaking change, so there's also a --strictNullChecks mode in case developers need to exclude this capability.

Tagged unions are now a working feature, something that was introduced in the 2.0 beta release back in August. "Tagged unions are an exciting new feature that brings functionality from languages like F#, Swift, Rust, and others to JavaScript, while embracing the way that people write JavaScript today," said Rosenwasser, in an earlier post. Other types that are now working but introduced into testing in earlier versions include the addition of more literal types, including boolean and enum types.

And finally, there's glob support, a feature that was introduced into testing with version 1.6. Rosenwasser notes that "Globs allow us to write out wildcards for paths, making them as granular as you need without being tedious to write." Globs could be used with the *, ?, and **/ wildcards.

To use TypeScript 2.0, developers will need to have Visual Studio 2015 Update 3; it's also available for developers using the latest version of the Visual Studio Code editor.

About the Author

Michael Domingo is a long-time software publishing veteran, having started up and managed several developer publications for the Clipper compiler, Microsoft Access, and Visual Basic. He's also managed IT pubs for 1105 Media, including Microsoft Certified Professional Magazine and Virtualization Review before landing his current gig as Visual Studio Magazine Editor in Chief. Besides his publishing life, he's a professional photographer, whose work can be found by Googling domingophoto.

comments powered by Disqus


  • Top 3 Blazor Extensions for Visual Studio Code

    Some developers prefer to create applications with Microsoft's open-source Blazor tooling from within the open-source, cross-platform Visual Studio Code editor. Here are the top tools in the VS Code Marketplace for those folk, as measured by the number of installations.

  • How to Invert a Machine Learning Matrix Using C#

    VSM Senior Technical Editor Dr. James McCaffrey, of Microsoft Research, explains why inverting a matrix -- one of the more common tasks in data science and machine learning -- is difficult and presents code that you can use as-is, or as a starting point for custom matrix inversion scenarios.

  • Microsoft Engineer: 'It's Time to Move OData to .NET 5'

    Microsoft engineer Sam Xu says "it’s time to move OData to .NET 5" and in a new blog post he shows how to do just that.

  • Microsoft Goes Virtual with Developer Education in Face of COVID-19

    Like many organizations that host developer educational events, Microsoft has gone virtual amid shelter-in-place directives and a surge in remote work stemming from the COVID-19 pandemic.

  • Microsoft Enhances Low-Code Power Apps

    Microsoft's nod to the low-code movement, Power Apps, has been enhanced with a bevy of new features, including mixed reality, canvas/model support in a new mobile app, UX improvements and more.

.NET Insight

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.

Upcoming Events