TypeScript 4 Released |
Written by Ian Elliot |
Friday, 21 August 2020 |
TypeScript 4.0 has been released with improvements to the build and editing processes, along with support for variadic tuple types. TypeScript is a superset of JavaScript that adds optional static types which can be checked by the TypeScript compiler to catch common errors in your programs. 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. Three new compound assignment operator is have also been added. Compound assignment operators apply an operator to two arguments, and then assign the result to the left side, but until now JavaScript lacked support for logical and (&&), logical or (||), and nullish coalescing (??). TypeScript has added support for a new ECMAScript feature to add three new assignment operators: &&=, ||=, and ??=. 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.
More InformationRelated ArticlesNew 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.
Comments
or email your comment to: comments@i-programmer.info |