// T: type parameter
function firstElement<T>(arr: T[]): T {
return arr[0];
}
// of type 'string'
const s = firstElement(["a", "b", "c"]); // "a"
// of type 'number'
const n = firstElement([1, 2, 3]); // 1
type parameters are for relating the types of multiple values (parameters or return value). If a type parameter is only used once in the function signature, it’s not needed after all.