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:
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.
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:
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.
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.
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 a few weeks. Read more about the Typescript 3.1 RC on Microsoft blog.
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.