TypeScript class vs interface vs type

This is a brain dump. It is in no way authoritative.

I want multiple objects...

...to have the same shape

  • use a type

...and to support inheritance

  • use an interface

...and to have the same behavior

  • use a class.

An additional feature of a class is encapsulation:

  • restrict outside access to some of the class's parts
  • bundle the class's behavior with the data it uses