What New in TypeScript 4.0

jayesh shinde
1 min readAug 31, 2020

--

Few Months back 3.8 and 3.9 version released which brought type-only imports/exports, along with ECMAScript features like private fields, top-level await in modules, and new export * syntaxes, improving the performance and scalability. This new TypeScript 4.0 is even performing better and getting closer towards languages like Swift and Kotlin.

What’s New Summary

What’s New? Let’s dive in to feature Which are most important to Developer Point of View.

unknown on catch Clauses

TypeScript 4.0 now lets you specify the type of catch clause variables as unknown instead. unknown is safer than any because it reminds us that we need to perform some sorts of type-checks before operating on our values.

Class Properties Inference from Constructors

TypeScript 4.0 can now use control flow analysis to determine the types of properties in classes when noImplicitAny is enabled.

In cases where not all paths of a constructor assign to an instance member, the property is considered to be potentially be undefined.

In cases where you know better (e.g. you have an initialize method of some sort), you’ll still need an explicit type annotation along with a definite assignment assertion (!) if you’re in strictPropertyInitialization.

--

--

jayesh shinde
jayesh shinde

Written by jayesh shinde

Full Stack Developer | React| Angular| Swift| Node| AWS

No responses yet