Typescript 3.7

The new version of TypeScript has been released and with it comes optional chaining as well as nullish coalescing!

05 Nov 2019


Elvis (operator) is in the house 🎉!

I have been waiting for these two operators for a while now and it seems its not only just me. In the 5 years that TypeScript has gone open-source, people have been asking for them since these operators do not exist in JavaScript.

Optional chaining

Optional chaining allows developers to write code that stops early where expressions are null or undefined. If you are familiar with the Elvis operators in C# this would look familiar to you.

// person object exists somewhere
// and could be null or undefined

const fullName = person?.fullName


As you can see, it is more concise. Previously it could look something like this:

const fullName = !!person ? person.fullName : undefined

if (!!person) {

Nullish coalescing

This operators allow us to define a default value if we encounter null or undefined. Take the example below.

const fullName = person.fullName ?? 'John Smith'

Previously, I would do something like this:

const fullName = person.fullName || 'John Smith'

More information about TypeScript 3.7 and the new features it brings can be seen here.

Similar Posts

Cypress Part I: Getting Started

In this new series, we look at how we could include Cypress as part of our testing strategy for our single page applications.

15 Nov 20195-minute read

Cypress: A New Way of Testing UI

Have you ever tested a single page app with Selenium? It can be cumbersome and flaky, Cypress aims to fix those issues.

03 Nov 20192-minute read

Cypress Part III: Request Stubbing and Spying

One of Cypress's most compelling features is the ability to stub and spy HTTP requests our web application makes.

13 Dec 20194-minute read