Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon

TypeScript 3.3 RC is here!

Save for later
  • 2 min read
  • 23 Jan 2019

article-image

Today, Microsoft announced the general availability of TypeScript 3.3 RC in a blog post. This version does not contain any major or breaking changes.

Better behavior while 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:

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at €18.99/month. Cancel anytime
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.

The --build mode’s --watch flag leverages incremental file watching as well in TypeScript 3.3. This can result in significantly faster builds with --build --watch. Reportedly, there was over 50% reduced build times.

Future of ESLint support in TypeScript

Announcing ‘TypeScript Roadmap’ for January 2019- June 2019

Introducing ReX.js v1.0.0 a companion library for RegEx written in TypeScript