News

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

Featured

  • Build Your First AI Applications with Local AI

    "AI right now feels like a vast space which can be hard to jump into," says Craig Loewen, a senior product manager at Microsoft who is helping devs unsure about making that first daunting leap.

  • On Blazor Component Reusability - From Day 0

    "We want to try to design from Day One, even Day Zero, with reusability in mind," says Blazor expert Allen Conway in imparting his expertise to an audience of hundreds in an online tech event on Tuesday.

  • Decision Tree Regression from Scratch Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of decision tree regression using the C# language. Unlike most implementations, this one does not use recursion or pointers, which makes the code easy to understand and modify.

  • Visual Studio's AI Future: Copilot .NET Upgrades and More

    At this week's Microsoft Ignite conference, the Visual Studio team showed off a future AI-powered IDE that will leverage GitHub Copilot for legacy app .NET upgrades, along with several more cutting-edge features.

  • PowerShell Gets AI-ified in 'AI Shell' Preview

    Eschewing the term "Copilot," Microsoft introduced a new AI-powered tool for PowerShell called "AI Shell," available in preview.

Subscribe on YouTube