TypeScript tutorialLesson 16Free preview
TS Basic Generics
This lesson is part of TypeScript · All levels
Summary
Generic allows one function or type to work for different data types without compromising type security. The generic parameters are written in square brackets like T and can be bounded by constraint extends. With generic, the components become reusable while remaining compiler-tested.
Key points
- Generic is written as <T>
- Constraints restrict the type of entry
- Type inferred from the naming argument
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.