This chapter covers complex types, such as arrays, tuples for returning multiple values, and indexable types. We will look at how to define and use interfaces, and how to build new types via the union or intersection of existing types. Thanks to this union and intersection of types, type-checking can benefit from the flexibility of JavaScript variables, in that they can hold several different types—ES6-style function definitions, with ES6 pattern matching, destructuring, and spread, features supported by TypeScript. These features help developers to write more concise and readable code, and deploy more flexible functions. All of the concepts that we explore will be explained simply, with concise examples.
The following topics will be covered in this chapter:
- Using arrays and tuples
- Defining and using interfaces, indexable types, and type inference...