As its Florida Ignite shindig looms large, Microsoft has settled on a Release Candidate for TypeScript 3.7 ahead of an imminent launch.
A few short months since version 3.6 put in an appearance, 3.7 adds all manner of goodies to delight the faithful, including optional chaining (an implementation of pipeline chain operators made a long-overdue appearance in PowerShell 7 this week).
Optional chaining in the TypeScript world will stop an expression being run if a
undefined is hit thanks to a new
?. operator. An example of the usage would be:
let x = foo?.bar.baz();
The snippet would compute
foo is defined, but return
foo itself is
The operator also crops up in optional element access and optional calls, which allows expressions to be conditionally call if they are not
It is undoubtedly a handy function, and an ECMAScript feature, although we have to confess it made the flow of our code a little trickier to read until one was quite familiar with the operator.
Linked to the optional chaining is nullish coalescing, a way of falling back to a default value when a
undefined is encountered. There are also new "assertion signatures" for typing purposes and improved support for functions that return
.tsx files instead in order to keep things up to date.
The feature can be turned off for particularly large projects.
The current plan calls for only minimal changes between now and the final TypeScript 3.7 release in "a couple of weeks."
Just in time for Ignite. ®