Updated 1 min read

Types vs Interfaces

Quick Explanation

You should use types by default until you need a specific feature of interfaces, like 'extends'.

  • Interfaces can't express unions, mapped types, or conditional types. Type aliases can express any type.
  • Interfaces can use extends, types can't.
  • When you're working with objects that inherit from each other, use interfaces. extends makes TypeScript's type checker run slightly faster than using &.
  • Interfaces with the same name in the same scope merge their declarations, leading to unexpected bugs.
  • Type aliases have an implicit index signature of Record<PropertyKey, unknown>, which comes up occasionally.

In the video, he says his new recommendation is to default to interface until you need a feature from types. But it isn’t exactly clear why, and he stands by the points in his article above. He also says he cares less about this; TypeScript is faster than ever. The main point is just to default to interface extends over type intersections. When you’re just declaring types, you can use them interchangeably.