Skip to main content

Generics

Generics provide a way to create reusable components

function identity<T>(arg: T): T {
return arg;
}
class GenericNumber<T> {
zeroValue: T;
add: (x: T, y: T) => T;
}