Suppose you write a helper firstItem(arr). If you type it with any[], you lose autocomplete on the returned item. Generics (<T>) act like a type placeholder—TypeScript remembers the exact type you passed in and preserves it on the return value!
ADVERTISEMENT