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

  • Creating Reactive Applications in .NET

    In modern applications, data is being retrieved in asynchronous, real-time streams, as traditional pull requests where the clients asks for data from the server are becoming a thing of the past.

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

Subscribe on YouTube