01Chapter 1: Why Generics ExistGenerics let one piece of TypeScript code work with different types while preserving the specific type used at each call. They solve a common problem: reusable code should not have to give up useful type information.2 min read
02Chapter 2: Generic Functions and Type ParametersThis chapter assumes you know basic TypeScript types, interfaces, type aliases, function annotations, union types, and basic class syntax. Generics build on those features by allowing one function or type to work with different data types without discarding type information.2 min read
03Chapter 3: How TypeScript Infers Type ArgumentsTypeScript can often choose the type arguments for a generic function from the values you pass to it. This process is called type argument inference. You should already know basic TypeScript types, interfaces, type aliases, functions, unions, and classes.2 min read
04Chapter 4: Generic Interfaces and Type AliasesAssume you know basic TypeScript types, interfaces, type aliases, functions, unions, and classes. This chapter focuses on putting type parameters on interfaces and aliases so one definition can describe many related types.2 min read
05Chapter 5: Generic ClassesThis chapter assumes you know basic TypeScript types, interfaces, type aliases, functions, union types, and class syntax. A generic class is a class that receives a type parameter. The parameter lets each instance work with a specific type while keeping type checking.1 min read
06Chapter 6: Constraining Type Parameters with extendsThis chapter assumes you know basic TypeScript types, unions, interfaces, type aliases, functions, and classes. You should also understand that a generic type parameter, such as T, represents a type chosen when code is used.2 min read
07Chapter 7: keyof and Indexed Access TypesThis chapter assumes you know object types, interfaces, unions, generic functions, and basic type parameters. You should also be comfortable reading expressions such as User["name"].2 min read
08Chapter 8: Default Type ParametersThis chapter assumes that you know basic TypeScript types, interfaces, type aliases, functions, unions, and generic type parameters. A default type parameter is a fallback type that TypeScript uses when code does not provide a type argument.2 min read
09Chapter 9: Mapped TypesMapped types create a new type by iterating over the properties of another type. They are useful when several properties need the same transformation, such as making every property optional or read-only.1 min read
10Chapter 10: Built-in Utility TypesThis chapter assumes you know basic TypeScript types, interfaces, type aliases, function annotations, unions, and classes. It also assumes you can read a generic type such as Box<string>.2 min read
11Chapter 11: Conditional TypesAssume you know basic TypeScript types, unions, interfaces, type aliases, and generic type parameters. Conditional types let one type choose another type based on a relationship between types. They are the type-level equivalent of an if statement.2 min read
12Chapter 12: Extracting Types with inferThis chapter assumes that you know basic TypeScript types, union types, type aliases, and conditional types. A conditional type chooses one type when a condition is true and another when it is false:2 min read
13Chapter 13: Distributive Conditional TypesAssume you know union types, generic type parameters, and basic conditional types. This chapter explains how a conditional type behaves when its checked type is a union.2 min read
14Chapter 14: Common Pitfalls and Good PracticeThis chapter assumes you know basic TypeScript types, interfaces, type aliases, functions, unions, arrays, and classes. The goal is to use generics when they preserve a useful relationship between types, not merely to make code look flexible.2 min read
15Chapter 15: Variance in Generic TypesAssume you know basic TypeScript types, unions, functions, interfaces, type aliases, and generic syntax. This chapter focuses on how a generic type changes when its type argument changes.2 min read