TypeScript 3.7 (Beta)
October 02, 2019
In the last post I've wrote about how you can incrementally bring the benefits of TypeScript's strict mode to all engineers on your team. Almost like a incredible coincidence TypeScript 3.7 Beta has been released today, including some of our most highly-requested features like Optional Chaining and Nullish Coalescing. Those features can help you write cleaner code when it comes down to Null Checking.
Let's have a look at an abstract of our coding conventions:
&&the value on the right of this operator will only be used when the expression on the left side of the operator evaluates to
||the value on the right of this operator will be used when the expression on the left of it evaluates to any falsy value (e.g.
const volume = (storage && storage.settings && storage.settings.volume) || 0.5;
const volume = storage?.settings?.volume ?? 0.5
In the example using
|| the volume would be evaluated to 0.5 even tough the value in the store was set to 0.
That's it. Happy Hacking. ✌️