10 Working with objects
This chapter covers
- Using shape types to describe objects
- Making shape types easier to use with aliases
- Creating unions of shape types
- Guarding shape types
- Creating and using type intersections
In this chapter, I describe the way that TypeScript deals with objects. As explained in chapters 3 and 4, JavaScript has a fluid and flexible approach to dealing with objects, and TypeScript aims to strike a balance between preventing the most common mistakes while allowing useful features to be preserved. This is a theme that is continued in chapter 11, where I describe the TypeScript support for using classes. Table 10.1 summarizes the chapter.
Problem |
Solution |
Listing |
---|---|---|
Describe an ... |
Get Essential TypeScript 5, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.