Sat Oct 7

  • In TypeScript using an interface versus using a type alias changes how the type is represented in IDE type tooltips. With interfaces, tooltips will show the name of the interface. For example interface Foo {} will show as Foo. However with type aliases the tooltips will contain the contents of the alias. For example type Foo = { a: string } will show as { a: string }. I prefer the way interfaces are presented because its much more readable than having the guts of many fields splayed into a tooltip. More details can be found in this SO thread. Noted in this thread are two additional benefits of interfaces in TypeScript:

** An interface can be named in an extends or implements clause, but a type alias for an object type literal cannot. ** An interface can have multiple merged declarations, but a type alias for an object type literal cannot.

However at least one advantage of type aliases in TypeScript is that they can alias anything (primitives, unions, etc.), not just objects.