Skip to content

Type vs Interface

Always aim for the highest type safety. Never use the any type.

We should always default to type unless there’s a valid use case for choosing interface.

There’s a really good article Type vs Interface: Which Should You Use? by Matt Pocock that goes in-depth on this topic.

In summary:

  • Interfaces can’t express unions, mapped types, or conditional types, and all of these are very useful in day-to-day frontend work.

  • 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 occasionally comes up.

  • Basically, the only pro of using interface over type is inheritance. extends makes TypeScript’s type checker run slightly faster than using &.