This content originally appeared on Bits and Pieces - Medium and was authored by Charuka Herath
My thoughts about TypeScript’s new release.

The stable version of TypeScript 4.2 was released on the 23rd of February. When I was researching the new version, I found some exciting features and breaking changes. So in this article, I will point out these features, discover how the latest version will impact developers, the developers’ perspective, which I have extracted from some of the developer communities, and finally conclude whether we need to update to 4.2.
If you are using VS Code, I suggest you download the VS Code Insider plugin for the latest TypeScript version or get editor support for Sublime via Sublime package controller.
Exciting features of TS 4.2
- Changes in Tuple Types.
- Abstract construct Signatures.
- Improvements were added to get a better understanding of the compile process.
- Improvements for in operator.
- Improved Type Alias.
Changes in Tuple Types.
Tuples are useful datatypes in programming whenever developers need to return multiple results from a function. As they’re immutable, tuples can use as keys for dictionary-type data.
One of the key features of TypeScript is that tuples can have optional elements and rest elements, which is excellent for readability and tooling.
The rest element is the elements that use to hold any number of parameters that can only be used within tuple types in TypeScipt.
In previous versions …rest can be used only as of the last element of a tuple. However, in version 4.2, TypeScript allows …rest elements at any of a tuple type.
Developer’s thoughts
One of the biggest problems with Typescript is that there are badly typed JavaScript libraries. However, it will take some time for developers to stop writing JavaScript. Until then, those libraries will not be ported to Typescript.
Also, it is good to have an ‘explain’ flag for types. For example, explain as “single typed”. Because this is one of the common problems among developers when merging interfaces, they are correctly imported.
Tip: Share components between projects using Bit (Github).
Bit makes it simple to share and reuse independent components between projects.
Use it to maximize code reuse, keep a consistent design, speed-up delivery, and build apps that scale.
Bit supports Node, TypeScript, React, Vue, Angular, and more.

Abstract Construct Signatures
Abstraction is one of the significant features of TyepScript. TypeScript allows developers to use the abstract modifier to mark a class as abstract. To create instances to extract properties and behaviors of abstract classes, developers need to follow a basic OOP concept, which is to extend the abstract class using a subclass and instantiate objects.
Also, Mixins is one of the cutting-edge methods of TypeScript, which is also related to the same topic.
Mixins: is a method of building up classes from reusable components by using more straightforward classes.
Before, version 4.2 there were some bugs when using mixins with abstract classes. Check the following code fragment.
Here, there is an error which is abstract constructor types cannot be assigned to non-abstract constructor types.
As the modification to this issue, version 4.2 allows developers to use the abstract modifier on constructor signatures.
let newConstructor: abstract new () => hasPrice = Candy;
Developer’s view
Usage of the abstract will not stop you from passing in other classes/constructor functions. The main advantage is that it’s safe to pass in either class type to a constructor.
How does it help in mixins? Now developers can use mixin factories in a way that supports abstract classes.
Improvements were added to get a better understanding of the compile process.
When developing complex projects, sometimes it is difficult and time-consuming when searching for TypeScript file definitions. Most of the time, it is a process of trial and error.
However, with version 4.2, it is possible to get names of files that TypeScript finds as a part of the project. Also, Typescript finds reasons for the files to be part of the compilation process.
Run tsc against the project folder will give you a result like below.

Improvements for in operator.
It is an error to use a primary variable on the right side of an in operator, a general rule in programming. However, until version 4.2, it was not there in TypeScript.
However, with the new update, TypeScript is strict to rules. So, in operator will not going to allow primitive data types on the right side.
“test var” in 31 // will immediate leads to an error.
According to TypeScript developers, the new improvement error will lead to three test case failures:
- keyofAndIndexedAccess
- inOperatorWithValidOperands
- conditionalTypeDoesntSpinForever
Improved Type Alias
In previous versions, TypeScript did not resolve types correctly. However, in most cases, TypeScript will return the correct types but not the valid alias, leading to a lack of readability and repeat the same code repeatedly.
Previously, instantiations of aliased an unidentified object, mapped, or conditional types with a new type alias would continue to display the original type alias in diagnostics, quick info, and declaration files. Now, the re-aliasing of such types consistently adopts and displays the new type alias.
Besides, instantiations of distributive types (such as homomorphic mapped types and distributive conditional types) now correctly preserve the original type alias when the instantiation results in a union type:
Developers View: What is Good
Destructured Variables Can Be Explicitly Marked as Unused is one of the remarkable changes added because most developers have encountered this issue and fixed it previously by adding prefixing with an additional underscore.
Union types, sum types are robust concepts invented by TypeScript. According to the developers, though, it is one of the features which more mainstream languages must-have. However, it is common in the functional and machine learning world.
Developers View: What is Bad?
Most of the developers like to enable noUncheckedIndexedAccess their codes. However, because of the new version’s sudden changes, it is unable to use because of the errors.
One of the required features of TyepScript is the strict flag that makes ‘as const’ implicit, which uses ‘const’ binding.
Finally, one of the developers’ issues is how all these quick features were adding to TypeScript.
With so many updates to TypeScript, people start wondering if there will be a point shortly that it becomes too complicated to know it all, just like C++.
Summery
In this article, I have discussed 05 features and how they will affect developers’ life. There are both the wrong side and the right side of the release. However, features like Changes in Tuple Types and abstract construct signatures will impact most of the developers’ code.
However, it is up to you to update the new version and focus on useful features and updates and add them to your project.
According to Developers, enabling features should do gradually, or they should be done in major releases. Otherwise, TypeScript will become C++ where no one knows it all (maybe the designers do).
Thank you for reading. Feel free to leave a comment down below and share your experience.
Read More
- 11 JavaScript and TypeScript Shorthands You Should Know
- Design Patterns in TypeScript
- React TypeScript: Basics and Best Practices
TypeScript 4.2 is Here. Here’s What I’m Excited About. was originally published in Bits and Pieces on Medium, where people are continuing the conversation by highlighting and responding to this story.
This content originally appeared on Bits and Pieces - Medium and was authored by Charuka Herath

Charuka Herath | Sciencx (2021-02-25T17:56:20+00:00) TypeScript 4.2 is Here. Here’s What I’m Excited About.. Retrieved from https://www.scien.cx/2021/02/25/typescript-4-2-is-here-heres-what-im-excited-about/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.