Type Variable

A type variable is the placeholder for a generic type in your generic code:

1
2
3
function yourGenericFunction<MyTypeVariable>(input: MyTypeVariable[]): number {
return input.length;
}

Type variables are written by using the angle brackets and defining a name for the variable (e.g. <T>). This construct is often referred to as the diamond operator because the angle brackets look like a diamond (<>, 💎).