Learning the latest features and configuring the compiler
In this section, we will learn about some newer features in TypeScript, as well as how to configure the TypeScript compiler. By learning about these newer features, we will be able to write cleaner and easier-to-read code, which, of course, will be beneficial for working with the app in a team. By using the configuration options of TypeScript, we can have the compiler work in the way we think is best for our project.
Optional chaining
Let's take a look at optional chaining. This feature will allow us to write simpler code, but also prevent a small class of errors having to do with null
objects. Let's create a file called optionalChaining.ts
and add the following code to it:
namespace OptionalChainingNS { interface Wheels { count?: number; } interface Vehicle { ...