Web Development

TypeScript 3.1 RC released

2 min read

Typescript 3.1 release candidate is here with a few breaking changes and a showcase of what’s there to come in Typescript 3.1. TypeScript 3.1 RC is meant to gather all feedback to ensure a smooth final release. Here are the breaking changes:

Support for Mappable tuple and array types

Mapping over values in a list is one of the most common patterns in programming. Typescript 3.1 RC introduces mapped object types when iterating over tuples and arrays. This means if you’re already using existing mapped types like Partial or Required from lib.d.ts, they also automatically work on tuples and arrays now.

Properties on function declarations

Traditionally, properties on function declarations has been done in Typescript using namespaces. They are internal modules which organize code and support the concept of value-merging, where you can add properties to classes and functions in a declarative way. But they come with their own problems:

  • ECMAScript modules have become the preferred format for organizing new code in the broader TypeScript & JavaScript community, and namespaces are TypeScript-specific.
  • Additionally, namespaces don’t merge with var, let, or const declarations

Now, in TypeScript 3.1, for any function declaration or const declaration that’s initialized with a function, the type-checker will analyze the containing scope to track any added properties.

As an added bonus, this functionality in conjunction with TypeScript 3.0’s support for JSX.LibraryManagedAttributes makes migrating an untyped React codebase to TypeScript significantly easier.

Vendor-specific declarations removed

TypeScript 3.1 RC now generates parts of lib.d.ts (and other built-in declaration file libraries) using Web IDL files provided from the WHATWG DOM specification. This makes lib.d.ts easier to keep up-to-date. However, many vendor-specific types have been removed.

Differences in narrowing functions

Using the typeof foo === “function” type guard may provide different results when intersecting with union types composed of {}, Object, or unconstrained generics.

You can have a look at the Typescript roadmap to get the whole picture of the release. The final release, Typescript 3.1, is expected to ship in just few weeks. Read more about the Typescript 3.1 RC on Microsoft blog.

Read Next

TypeScript 3.0 is finally released with ‘improved errors’, editor productivity and more.

TypeScript 3.0 release candidate is here.

How to install and configure TypeScript.

Sugandha Lahoti

Content Marketing Editor at Packt Hub. I blog about new and upcoming tech trends ranging from Data science, Web development, Programming, Cloud & Networking, IoT, Security and Game development.

Share
Published by
Sugandha Lahoti

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago