Generics
This section covers preserving relationships between input and output types without giving up reuse. Every lesson stands alone while fitting the beginner-to-staff progression.
Learning outcomes
- Explain runtime and compile-time responsibilities.
- Write a correct example without unsafe escape hatches.
- Diagnose a representative compiler error.
- Identify API, performance, security, and production trade-offs.
- Apply the concept in a project or interview.
Lessons
- Generic Motivation
- Generic Functions
- Generic Interfaces
- Generic Type Aliases
- Generic Classes
- Type Parameters
- Generic Constraints
- keyof Constraints
- Multiple Type Parameters
- Generic Defaults
- Inference in Generics
- Higher-Order Generics
- Generic Factories
- Generic React Components
- Generic API Clients
- Common Generic Mistakes
Study method
Run the examples under strict checking, intentionally introduce an error, explain the diagnostic, and finish the exercises.