The Differences between Type Aliases and Interfaces
This lesson highlights the differences between type aliases and interfaces.
We'll cover the following
As TypeScript evolved, the differences between type aliases and interfaces have diminished. Nevertheless, few differences are worth pointing out.
Difference with classes
It is only ever possible to implement an interface on a class, but never a type. At any time, an interface is implementable, but a type cannot have a union.
This makes the type
a little more tricky to reuse in some patterns. The following example works because there is no union on line 1. Thus, line 6 transpiles. Line 10 remains legit because an interface can always be implemented by a class.
Get hands-on with 1200+ tech skills courses.