|TypeScript 4 Released|
|Written by Ian Elliot|
|Friday, 21 August 2020|
Shortly after the launch of a new website for TypeScript comes the release of a new major update. One of the main changes to the new release is support for Variadic Tuple types.Standard TypeScript tuples are types that works like arrays with a fixed number of elements of known types.
Variadic tuples can be used to define a tuple type that has the same properties — defined length and the type of each element is known — but where the exact shape is yet to be defined. Using variadic tuples means you can use the rest operator to pass types through the type checker in a way that works like generics.
In addition, spreads in tuple type syntax can now be generic. This makes it possible to represent higher-order operations on tuples and arrays even when the actual types being operating over aren't known. When generic spreads are instantiated or replaced with a real type, they can produce other sets of array and tuple types. More generally with tuples, you can now have labelled tuple elements to make code more readable.
Other improvements include support for class property inference from constructors, meaning TypeScript can now use control flow analysis to determine the types of properties in classes when noImplicitAny is enabled.
Support has also been added for custom JSX factories. JSX uses fragments, a type of JSX element that can return multiple child elements. TypeScript's support for this wasn't the same as in other libraries, so TypeScript 4 has changed its technique so users can customize the fragment factory through the new jsxFragmentFactory option.
New TypeScript Website Launched
TypeScript 3.6 Generators Get Stricter
TypeScript 3.5 Adds Smart Select
TypeScript 3.2 Gets Stricter Checking
TypeScript 3.1 Adds Mappable Tuples
TypeScript 3.0 Adds Project References
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
or email your comment to: email@example.com