After releasing TypeScript 3.3 RC, two weeks ago, yesterday Microsoft announced the availability of TypeScript 3.3. TypeScript 3.3 contains no breaking changes and is a comparatively smaller release than usual.
What’s new in Typescript 3.3
Better behavior when calling union types
When there is a union type A | B, TypeScript now allows users to access all of the properties common to both A and B. For example, the intersection of members. You can get a property from a union type only if it’s known to be present in every union type. When every type has only one signature with identical parameters, things work. Such a restriction was too much and have errors in some areas. So, in TypeScript 3.3, the following code as shown in the blog will work:
type Fruit = "apple" | "orange"; type Color = "red" | "orange"; type FruitEater = (fruit: Fruit) => number; // eats and ranks the fruit type ColorConsumer = (color: Color) => string; // consumes and describes the colors declare let f: FruitEater | ColorConsumer; f("orange"); // It works! Returns a 'number | string'. f("apple"); // error - Argument of type '"apple"' is not assignable to parameter of type '"orange"'. f("red"); // error - Argument of type '"red"' is not assignable to parameter of type '"orange"'.
The parameters of the above signatures are ‘intersected’ to create a new signature. When the impossible intersections are gone, what remains is “orange” & “orange” which is just “orange”. That is not to say there are no restrictions. The new behavior is active only when only one type in the union has multiple overloads and a generic signature. The forEach method will now be callable, but there may be some issues under noImplicitAny.
–build –watch use incremental file watching
In TypeScript 3.3, –build mode’s –watch flag leverage incremental file watching. This results in significantly faster builds with a reduction of 50% to 75% in build times of the original –build –watch times.
Typescript recently announced the ‘TypeScript Roadmap’ for January 2019- June 2019 which outlines the priorities that the team will be focussing on, over the next 6 months.
Future of ESLint support in TypeScript
PayPal replaces Flow with TypeScript as their type checker for every new web app