We can also define generic interfaces using the type variable T, as follows:
interface GenericFunc<T> {
(arg: T): T;
}
function func<T>(arg: T): T {
return arg;
}
var myFunc: GenericFunc<number> = func;
Here, we defined a generic interface and the myFunc variable of the GenericFunc type, passing the number data type for the type variable T. Then, this variable is assigned with a function named func.