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


  • 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