Modernizing your code with powerful language features
TypeScript is an integral part of Angular, but because Angular has its own compiler transformations that extend TypeScript's compilation steps, we are inevitably tied to the version of TypeScript that the Angular compiler supports. Fortunately, Angular is good at keeping up with recent versions of TypeScript. In this section, we are going to discuss some of the most noteworthy additions to the TypeScript language in the most recent versions supported by Angular Ivy.
The optional chaining operator
TypeScript version 3.7 introduces a new operator for optional property access, optional element access, and optional calls. The optional chaining operator (?.
) short circuits in the case of nullish values – that is, null
or undefined
– in which case it evaluates to undefined
.
Optional chaining is great for working with composite objects or just plain old complex data structures such as large business documents...