Microsoft has lifted the lid on a “feature complete” beta of TypeScript 3.7, claiming that it includes some of the most highly-requested features from end users, such as optional chaining.
The feature Microsoft is making most noise about in this release is optional chaining, which it said is one of one of the most highly demanded requests by developers. Optional chaining essentially allows developers to write code that references object properties that may or may not exist. Instead of triggering an error, it simply returns
undefined if the object does not exist.
TypeScript 3.7 employs a new
?. operator to signify such optional property accesses in code, and several can be strung together to reference nested objects – hence optional chaining.
Optional chaining in TypeScript 3.7 also includes two other operations. One is optional element access, which provides a similar function to optional property accesses but allows access to non-identifier properties such as arbitrary strings, numbers, and symbols. The second is optional call, which allows users to conditionally call expressions if they are not
Another feature adopted from the ECMAScript specifications is nullish coalescing. This is a rather unhelpful name for simply allowing a developer to specify a value for something if a property being referenced turns out to be
Other new capabilities added include Assertion Functions, better support for functions that return a value of
never and more recursive type aliases. For full details, see Microsoft’s TypeScript developer blog post announcing the beta.
TypeScript 3.7 also implements a better experience for
editing large projects that have been broken up into smaller chunks using project
references. When opening a project with dependencies, TypeScript will
automatically use the source
.tsx files instead. This
means projects using project references will now provide an improved experience
where semantic operations are up-to-date and “just work”, according to
The final release of TypeScript 3.7 is due for delivery at the start of November, with a release candidate set to be available a few weeks earlier. Developers interested in evaluating the beta can get it through NuGet or download it for Visual Studio 2019/2017.