See Generics in the handbook.

As in C# and Java, you can create a component that can work over a variety of types which makes them resuable.

Rather than setting a type like number or using any, you can let the type be defined based on the usecase.

Type alias

type Container<T> = { value: T };

Function

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

You can use like this:

let foo = identity("bar");

Which implies:

let foo: string = identity<string>("bar")