News

What's New in TypeScript 3.2 Release Candidate

Microsoft shipped the release candidate of TypeScript 3.2, its open source take on the JavaScript programming language that allows for optional static typing, among other features.

The next edition of the popular language includes tweaks affecting binding, working with generics and new BigInt functionality.

For generics, TypeScript now allows for using "spreads" on generic types, using the spread operator ("..."), which lets an iterable expand in places where arguments are expected, allowing, for example, taking an object like an array and expanding it into a set of items that can be copied into another array.

"TypeScript does a pretty good job here when it has enough information about the type," Microsoft's Daniel Rosenwasser said in a post yesterday. "The type system closely tries to model the behavior of spreads and overwrites new properties, tries to ignore methods, etc. But unfortunately up until now it wouldn’t work with generics at all."

This complex problem was solved after a lot of thought, but the end result is "TypeScript 3.2 now permits object spreads on generics and models them using intersections."

Generics can also be used with the object rest pattern, which is akin to spreads in that it creates a new object wherein certain properties are excluded. The team figures out how use rest with generic objects.

The new edition also provides stricter checking for bind, call and apply, described by Rosenwasser as "methods on functions that allow us to do things like bind this and partially apply arguments, call functions with a different value for this, and call functions with an array for their arguments."

The team figured out how to model these patterns in a type-safe way, with the upshot being a mechanism to "ensure our uses of bind, call, and apply are more strictly checked when we use a new flag called strictBindCallApply."

Finally, Rosenwasser discussed BigInt support to let coders model theoretically arbitrarily large integers, a feature in an upcoming proposal for ECMAScript, upon which JavaScript and derivatives like TypeScript are based.

"TypeScript 3.2 brings type-checking for BigInts, as well as support for emitting BigInt literals when targeting esnext," Rosenwasser said. "BigInt support in TypeScript introduces a new primitive type called the bigint (all lowercase)." He emphasized that BigInt support is only available for the esnext target (indicating a future version of ECMAScript yet to be released).

Coincidentally with yesterday's announcement of TypeScript 3.2 RC, GitHub also published a post examining what makes programming languages popular, in which it noted the fast rise of TypeScript.

"TypeScript entered the top 10 programming languages for public, private, and open source repositories across all regions last year," GitHub said.

Furthermore, GitHub noted that TypeScript fared well in its three indicators of programming language popularity: thread safety ("TypeScript’s optional static typing adds an element of safety."); interoperability ("Part of the reason TypeScript has climbed our rankings is because of its ability to coexist and integrate with JavaScript."); and being open source (TypeScript development takes place on GitHub).

GitHub is also the place where you can go to find out what features are planned for future versions of TypeScript in the roadmap.

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus

Featured

  • What's Next for ASP.NET Core and Blazor

    Since its inception as an intriguing experiment in leveraging WebAssembly to enable dynamic web development with C#, Blazor has evolved into a mature, fully featured framework. Integral to the ASP.NET Core ecosystem, Blazor offers developers a unique combination of server-side rendering and rich client-side interactivity.

  • Nearest Centroid Classification for Numeric Data Using C#

    Here's a complete end-to-end demo of what Dr. James McCaffrey of Microsoft Research says is arguably the simplest possible classification technique.

  • .NET MAUI in VS Code Goes GA

    Visual Studio Code's .NET MAUI workload, which evolves the former Xamarin.Forms mobile-centric framework by adding support for creating desktop applications, has reached general availability.

  • Visual Studio Devs Quick to Sound Off on Automatic Updates: 'Please No'

    A five-year-old Visual Studio feature request for automatic IDE updates is finally getting enacted by Microsoft amid a lot of initial developer pushback, seemingly misplaced.

  • First Official OpenAI Library for .NET Goes Beta

    Although it seems Microsoft and OpenAI have been deeply intertwined partners for a long time, they are only now getting around to releasing an official OpenAI library for .NET developers, joining existing community libraries.

Subscribe on YouTube