TypeScript is an open-source programming language developed by Microsoft and has been gaining popularity in an exponential way in the developers’ world. This language adds static type-checking along with type syntax which helps in detecting the problems with the code before running it by reporting errors if something questionable is done.
The updated version, Typescript 3.7 was released on 5 November 2019 which includes various intuitive features. In the previous versions, this language had features which included features like:
- Quick fixes
This time, the updated version not only includes one of the highly-demanded ECMAScript features, optional chaining and nullish coalescing but many other intuitive features.
The features included in version TypeScript 3.7 are mentioned below
- Optional Chaining
As mentioned, Optional Chaining is one of the most highly-demanded ECMAScript features in TypeScript. The issue of optional chaining is not new and according to the developer community, the issue has been filed 5 years ago. This feature is mainly used for syntax and messaging purposes where it allows the developers to write codes where they can immediately stop running some expressions if they run into a null or undefined.
Besides the new ?. operator for optional property accesses, optional chaining also includes two other operations which are the optional element access which acts similarly to optional property accesses but allows the developers to access non-identifier properties. The second operation is the optional call which allows us to conditionally call expressions if they’re not null or undefined.
- Nullish Coalescing
Nullish Coalescing is another ECMAScript feature which goes hand-in-hand with optional chaining. For this feature, the ?? operator works as a way to fall back to a default value when dealing with null or undefined.
- Assertion Functions
The assertion functions are a specific set of functions which throw an error if something happens unexpectedly. TypeScript 3.7 introduces a new concept called “assertion signatures” which model the assertion functions. It ensures that whatever condition is being checked must be true for the remainder of the containing scope.
- Better Support For Never-Returning Functions
This feature is related as a part of assertion signatures. It ensures that a function never potentially returned undefined or effectively returned from all code paths. If it happens and never-returning functions are called, TypeScript recognises that the control flow graph has been affected and thus accounts for it.
- –declaration and –allowJs
- (More) Recursive Type Aliases
Type aliases have always had a limitation in how they could be “recursively” referenced. TypeScript 3.7 mitigates this issue by resolving type arguments at the top level of a type alias.
- The useDefineForClassFields Flag and The declare Property Modifier
TypeScript 3.7 provides a new flag called useDefineForClassFields to enable a logically enhanced emit mode. In this case, the declarations will be initialised with Object.defineProperty and they will always be initialised to undefined, even if they have no initialiser.
The other features included in TypeScript 3.7 are Build-Free Editing with Project References, Uncalled Function Checks, Flatter Error Reporting, // @ts-nocheck in TypeScript Files, Semicolon Formatter Option, Website and Playground Updates and Breaking Changes.
For those who have not tried their hands on TypeScript, Playground is exclusively made for them. TypeScript 3.7 has updated it and one can test out the programming language in TypeScript Playground.
Subscribe to our NewsletterGet the latest updates and relevant offers by sharing your email.
What's Your Reaction?
A Technical Journalist who loves writing about Machine Learning and Artificial Intelligence. A lover of music, writing and learning something out of the box. Contact: email@example.com