Optional Chaining
before 3.7:
let x = (foo === null || foo === undefined) ?
undefined :
foo.bar.baz();
After 3.7
let x = foo?.bar.baz();
Nullish Coalescing
before 3.7:
let x = (foo !== null && foo !== undefined) ?
foo :
bar();
after 3.7:
let x = foo ?? bar();
Uncalled Function Checks
In 3.7
interface User {
isAdministrator(): boolean;
notify(): void;
doNotDisturb?(): boolean;
}function doAdminThing(user: User) {
if (user.isAdministrator) {
// ~~~~~~~~~~~~~~~~~~~~
// error! This condition will always return true since the function is always defined.
// Did you mean to call it instead?t
These are the things that stick out for me! Alot more can beread on the official blog of microsoft:
Enjoy!