Generics

Generics allow the creation of reusable components that work with different types.

Snippet:

function identity<T>(arg: T): T { return arg; }

Example:

const numberIdentity = identity<number>(42);