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

  • Blazor's Future: gRPC Is Key

    Blazor guru Steve Sanderson detailed what Microsoft is thinking about the future of the revolutionary project that enables .NET-based web development using C# instead of JavaScript, explaining how gRPC is key, along with a new way of testing and a scheme for installable desktop apps.

  • Don't Do It All Yourself: Exploiting gRPC Well Known Types in .NET Core

    If you're creating business services that send dates and decimal data then you may be concerned that gRPC services don't support the relevant data types. Don't Panic! There are solutions. Here's how to use them.

  • Sign

    Microsoft Points Blazor to Native Mobile Apps

    Blazor, the red-hot Microsoft project that lets .NET developers use C# for web development instead of JavaScript, is now being pointed toward the mobile realm, targeting native iOS and Android apps.

  • Circl

    Implementing State in .NET Core gRPC Messages with oneof

    In the real world, you've been dealing with the State pattern every time you designed a set of database tables. The Protocol Buffers specification lets you do the same thing when you define the messages you send and receive from your gRPC Web Service.

  • C#, .NET and SQL Server Make List of Top In-Demand Programming Skills

    Microsoft-centric technologies are featured prominently in a new examination of the top in-demand programming skills published by careers site Dice.com.

.NET Insight

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.

Upcoming Events