Let’s get into our main topic that is about the new things in TypeScript 4.0
You will get the following things
- Better Editor with new improvements
- Labeled Tuple Elements
- Variadic tuple types
- Custom JSX factories
- Class property interference directly from Constructors
- Short-circuiting assignment operators
- Unknown on Catch clauses
- — incremental with — noEmit
That’s not all, they have also got a new website where you can find more information about the language. Some of these are self-explanatory whereas some of them need an overview. Let’s get into that.
One of the biggest issues that the editor faced was regarding optional chaining. The website just broke if the developer didn’t use proper chaining. This happened with the fields such as address. Now, the new TypeScript 4.0 can suggest you convert it to option chaining.
The next change is the partial semantic mode at startup. This will improve the opening time (no more waiting in big projects). Of course, there is a smart import that can auto-import the files.
Also, TypeScript now supports
There are two new things regarding tuple. One of them is the variadic tuple type.
Let’s say, there are various tuple types in the code. The type of the tuple is unknown. The new TypeScript will assign it as an array type. Further, TS 4 can also count the number of types.
It allows the developers to label the tuple. This has various usage. It will decrease the code complexity and it will also decrease the load. The auto-suggestion will only show the type name. The developer can then choose the type they want.
Class Properties and Catch Clauses
The developers can now use the unknown on catch clauses. It helps with the entire error handling problem. This will enhance your try..catch block a little more.
Further, you can also access the class properties from the constructor. In simpler words, a constructor can also analyze the path of the class. Isn’t this amazing? This will also increase the security of the code along with the efforts.
The next best thing about TS 4 is the compound operators. Like we mentioned earlier, you can now use three more compound operators that were previously now supported.
The three compound operators are logical and (&&), logical or (||), and nullish coalescing (??).
Many developers who are costly using them will find TS more amazing.
Last but not the least, they have also announced the official website. You can see the docs from there or you can also talk with the developer’s community. There is a handbook if you are new to TypeScript.