13 Advanced generic types
This chapter covers
- Using the JavaScript collection types with generic type parameters
- Iterating over type-safe collections
- Creating collection keys with index types
- Transforming types with mappings
- Using the built-in type mappings
- Selecting generic types with conditional type expressions
In this chapter, I continue to describe the generic type features provided by TypeScript and focus on the advanced features. I explain how generic types can be used with collections and iterators, introduce the index types and type mapping features, and describe the most flexible of the generic type features: conditional types. Table 13.1 summarizes the chapter.
Problem |
Solution |
Listing |
---|
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.