TypeScript 3.7 has Been Released

Recently, Microsoft announced the latest version of TypeScript i.e. 3.7. The new release brings new language, compiler, and tooling features.

Well, TypeScript is a language based on JavaScript that provides static type-checking along with type syntax. It powers things like completions, quick fixes, and refactorings for both TypeScript and JavaScript in many of the editors.

You can get the latest version through NuGet, or using npm - npm install typescript

3.7 brings some great features like Optional Chaining, Nullish Coalescing, Better Support for never-Returning Functions, and Assertion Signatures

You can check out the TypeScript playground where you will find an entire menu for learning what’s new.

This is image title

Source: Microsoft

New feature Optional chaining allows you to write code where you can immediately stop running some expressions if you run into a null or undefined. Consider the following code:

let x = foo?.bar.baz();  

that means when foo is defined, foo.bar.baz() will be computed, but incase foo is null or undefined, it will stop and return undefined.

And, the nullish coalescing operator(??) is a feature that goes hand-in-hand with optional chaining. ?? operator is a way to fall-back to a default value when dealing with null or undefined. So if you write a code like:

let x = foo ?? bar();  

it means the value foo will be used when it’s present; but if it is null or undefined, it will calculate bar() in its place.

TypeScript 3.7 brings a new concept - assertion signatures - which model the assertion functions.

Here, one type of assertion signature models the way that Node’s assert function works. It makes sure that whatever condition is being checked must be true for the remainder of the containing scope. While, the other type of assertion signature, instead of checking for a condition, tells TypeScript that a specific variable or property has a different type.

Other important features, included in 3.7 are:

  • –declaration and --allowJs
  • (More) Recursive Type Aliases
  • The useDefineForClassFields Flag and The declare Property Modifier
  • 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 include DOM Changes, Class Field Mitigations, Local and Imported, _Type Declarations Now Conflict, Function Truthy Checks, and API Changes

You can visit the official announcement here.

Thank you !

#TypeScript #TypeScript 3.7 #JavaScript

TypeScript 3.7 has Been Released
1 Likes5.80 GEEK