There are numerous ways to make your code more extensible, maintainable, and, most importantly, reusable. One such way, which we will discuss now, is through the usage of generic, or parameterized, types. Simply put, as their name suggests, they allow you to write more generic code. Generic code is great because it can help you to avoid duplication and increase reusability.
Generics allow you to write code that works with a variety of types instead of just a single type. They allow you to abstract over types by enabling classes, types, and interfaces to act as parameters. In practice, using generics means that you can pass different types as parameters, making your types and functions more open and reusable.
Generics are supported in many languages such as C++, Java, C#, and Haskell. And, last but not least, TypeScript, of course, also supports generics! This is great because it means that once you are familiar with the concept, you'll be able to leverage that knowledge in TypeScript and in any other language.