Skip to content
Back to blog

TypeScript

Notes on the semantic purposes of type and interface in TypeScript, and how they display differently in VSCode type hints.

Updated

Differences Between type and interface

Different Semantics

  • interface is mainly used to define data types, abstract interface capabilities of a class, and so on.
  • type is more often used for type operations, such as type gymnastics and generated types.

Multiple Inheritance

  • interface does not support multiple inheritance; extends can only extend a single interface or type
  • type can extend multiple types

VSCode Type Hint Rendering

  • In VSCode hover hints, an interface is generally displayed as the interface name
  • In VSCode hover hints, a type is generally displayed as the complete object, that is, in key-value form