Microsoft Releases TypeScript v3.3

Microsoft has released TypeScript v3.3 which brings better behavior in calling union types, incremental file watching for composite projects, and support for JavaScript editing in Sublime Text.

Recently, Microsoft has released the latest version of TypeScript - v3.3. which brings better behavior in calling union types, Incremental file watching for composite projects in --build --watch and support for JavaScript editing in Sublime Text.
 
TypeScript is a language that enables static type-checking in JavaScript. This allows you to catch issues before you even run your code. It also includes the latest features of JavaScript from the ECMAScript-standard on older browsers and runtimes by compiling those features into a form that they understand.
 
According to the company, 3.3 is a smaller release than usual and contains no breaking changes, so it will be easy to upgrade if you are using an older version.
 
The official blog highlighted that in TypeScript 3.3, the parameters of the signatures are intersected together to make a new signature.
 
In the code below, the parameters fruit and color are intersected together to make a new parameter of type Fruit & Color. Fruit & Color is same as ("apple" | "orange") & ("red" | "orange") which is equivalent to ("apple" & "red") | ("apple" & "orange") | ("orange" & "red") | ("orange" & "orange"). All impossible intersections evaporates, and only left is "orange" & "orange" which is just "orange".
  1. type Fruit = "apple" | "orange";  
  2. type Color = "red" | "orange";  
  3.   
  4. type FruitEater = (fruit: Fruit) => number;     // eats and ranks the fruit  
  5. type ColorConsumer = (color: Color) => string;  // consumes and describes the colors  
  6.   
  7. declare let f: FruitEater | ColorConsumer;  
  8.   
  9. f("orange"); // It works! Returns a 'number | string'.  
  10.   
  11. f("apple");  // error - Argument of type '"apple"' is not assignable to parameter of type '"orange"'.  
  12.   
  13. f("red");    // error - Argument of type '"red"' is not assignable to parameter of type '"orange"'.  
But this new behavior works only when at most one type in the union has multiple overloads, and at most one type in the union has a generic signature.
 
TypeScript 3.0 introduced a new feature for structuring builds - composite projects. One of the reasons was to enable users in breaking up large projects into smaller parts that build quickly and preserve project structure, without any compromise in the existing TypeScript experience.
 
Now TypeScript 3.3's --build mode's --watch flag does leverage incremental file watching as well. This functionality has provided a reduction of 50% to 75% in build times of the original --build -watch times.
 
With the new release, the TypeScript plugin for Sublime Text now supports editing in JavaScript files.
 
To learn more, you can visit the official announcement here.
 
Also, you can regularly visit the TypeScript category for all the latest articles, tutorials, news, blogs, and resources.