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
interfaceis mainly used to define data types, abstract interface capabilities of aclass, and so on.typeis more often used for type operations, such as type gymnastics and generated types.
Multiple Inheritance
interfacedoes not support multiple inheritance;extendscan only extend a singleinterfaceortypetypecan extend multiple types
VSCode Type Hint Rendering
- In VSCode hover hints, an
interfaceis generally displayed as theinterfacename - In VSCode hover hints, a
typeis generally displayed as the complete object, that is, inkey-valueform