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.
- Ian Elliot is the author of several JavaScript titles. Just JavaScript: An Idiomatic Approach is intended for programmers who are familiar with another language, and which takes a radical look at JavaScript that takes account of the way it is object-based. JavaScript Async covers asynchronous programming in JavaScript, async/await, Promises, Service Workers and so on. His latest book, JavaScript Bitmap Graphics with Canvas shows you how to use Canvas to create graphics without resorting to a library of any kind.
More Information
Related Articles
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.
Microsoft Announces GitHub Copilot App For Java And .NET
27/10/2025
GitHub Copilot has been updated with app modernization features for Java and .NET applications. The news was announced by Microsoft at last month's Migrate and Modernize Summit, alongside new ag [ ... ]
Google AI Studio Does Angular
27/10/2025
Google's AI Studio can now generate Angular applications. Add the Web Codegen Scorer tool on top and you get a pretty solid Angular development platform.
- Windows XP Crocs Now On Sale
- W3C Adopts A New Logo
- Join The Protest Against The Closing Of Android
- Apache Grails 7.0 Released
- XAML.io 0.5 Adds Multi-File Project Editing
- What Does JetBrains Survey Tell Us About AI
- Epic Settles With Google - Abandons The Rest Of Us
- Formae Launched As Terraform Alternative
- The Pico Gets Zephyr And Rust Support
- InfluxDB 3.6 Released With AI Capabilities
- Julia 1.12 Adds Trim Feature
- GitHub Copilot CLI And Spaces In Preview
- Deepnote Goes OpenSource
Comments
or email your comment to: comments@i-programmer.info