Tagged Unions, More Literals Previewed in TypeScript 2.0 RC

This TypeScript 2.0 release candidate shows off a few new features, such as tagged unions and support for more literal types, and flexes itself beyond excludes in the config file with support for globs and includes. Bonus: It's "stable enough for general use," says Microsoft.

Microsoft made a release candidate of TypeScript 2.0 available at the end of August that goes beyond just fixes from the last beta test version. This RC debuts a few new features, such as tagged unions and additional literals support, and it flexes itself beyond excludes in the config file with support for globs and includes. Unlike most RCs, this one can be put to use without having to wait for the final version.

"This RC gives an idea of what the full version of 2.0 will look like, and we're looking for broader feedback to stabilize and make 2.0 a solid release," writes Daniel Rosenwasser, a Microsoft Program Manager for TypeScript, in a blog post. "Overall, the RC should be stable enough for general use, and we don't expect any major new features to be added past this point."

One highlight among the new features that Rosenwasser highlights is tagged unions, which "brings functionality from languages like F#, Swift, Rust, and others to JavaScript, while embracing the way that people write JavaScript today." Version 2.0 rids the use of boilerplate that was necessary to tag unique values to types with common fields.

Rosenwasser also highlights support for literal types beyond string, with support for unique boolean, number and enum member types.

One other new addition is support for glob and include fields within the TypeScript config file. TypeScript 1.6 introduced the exclude field, which was useful for excluding a list of files. Globs go a step further, allowing the use of wildcards in path names. With the addition of the new include field makes including or excluding files in the config less tedious.

TypeScript 2.0 RC is available on GitHub. It does require Visual Studio 2015 Update 3 to run.

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


  • 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.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube