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


  • 'Dev Home' Update Leads Developer Goodies in AI-Powered Windows 11 Update

    Along with today's new AI-powered Windows 11 update come new goodies for developers, including a new edition of Dev Home, a preview offering described as a "control center" providing coding-focused features and functionality.

  • Community Dev Gives VS Code Python Some YAPF

    The latest update to Python in Visual Studio Code includes a new extension for Python formatting that was contributed by a member of the open source community.

  • Devs Demand Visual Studio 2022 Ditch Old .NET Framework Dependencies

    Developers commenting on a Microsoft post about performance improvements in the upcoming .NET 8 demanded the company end Visual Studio 2022's dependency on the old .NET Framework.

  • Microsoft Remakes Azure Quantum Dev Kit with Rust, 'and It Runs in the Browser!'

    "The' tl;dr' is that we rewrote it (mostly) in Rust which compiles to WebAssembly for VS Code or the web, and to native binaries for Python."

Subscribe on YouTube