TypeScript 3.7 beta debuts with optional chaining


The next version of TypeScript, Microsoft’s typed superset of JavaScript, will include optional chaining, an ECMAScript feature that allows developers to stop running expressions if they encounter a null or undefined value. 

A beta version of TypeScript 3.7 was released October 1, with general availability planned for early November. A release candidate is due before then.

Optional chaining uses a new ?. operator for optional property accesses. Also included are two other operations: optional element access, for accessing non-identifier properties such as numbers and arbitrary strings, and optional call, for conditionally calling expressions if they are not null or undefined.

Other highlights of TypeScript 3.7 include:

  • A nullish coalescing operator, an upcoming ECMAScript feature that is paired with operational chaining, that provides a way to fall back to a default value when working with null or undefined, via a ?? operator.
  • Improved support for never-returning functions. The intent of the never function is that it never returns, indicating an exception was thrown, a halting error condition occurred, or a program exited.
  • Assertion signatures, which model assertion functions. The first assertion signature models the Node assert function, ensuring that whatever condition is being checked must be true for the remainder of the container scope. Also, asserts condition stipulates that whatever is passed into the condition parameter has to be true if the assert returns. Another type of assertion signature does not check for a condition but tells TypeScript that a specific variable or property has a different type.
  • The ability to add // @ts-nocheck comments at the top of TypeScript files to disable semantic checks.
  • When opening a project with dependencies, TypeScript will use source .ts/.tsx files instead of project references, to provide a better editing experience.
  • The built-in formatter now supports semicolon insertion and removal where a trailing semicolon is optional because of JavaScript’s automatic semicolon insertion rules.
  • More recursive type aliases.
READ ALSO  Someone sent us 21 more pictures of the leaked Pixel 4 XL

Where to download TypeScript 3.7

You can download the TypeScript 3.7 beta through NuGet or via NPM:

    npm install typescript@beta



Source link

?
WP Twitter Auto Publish Powered By : XYZScripts.com