Generics
Generics let you write a function or type once and have it work correctly with whatever type gets passed in, without losing type safety.
TypeScript
Think of <T> as a placeholder: "whatever type you give me, I'll give the same type back out." The compiler figures out T automatically from the argument you pass, and still catches mistakes, firstElement([1, 2, 3])[0].toUpperCase() would be a compile error because that element is a number, not a string.