Skip to main content


Learning TypeScript's Generics chapter covers making classes, functions, interfaces, and type aliases "generic" by allowing them to work with type parameters:

  • Using type parameters to represent different types between uses of a construct
  • Providing explicit or implicit type arguments when calling generic functions
  • Using generic interfaces to represent generic object types
  • Adding type parameters to classes, and how that impacts their types
  • Adding type parameters to type aliases, in particular with discriminated type unions
  • Modifying generic type parameters with defaults (=) and constraints (extends)
  • How Promises and async functions use generics to represent asynchronous data flow
  • Best practices with generics, including their Golden Rule and naming conventions