What’re the Interfaces in TypeScript, and What’s the Difference Between Type Aliases and Interfaces?
I’ve been learning TypeScript for a while and, I decided to publish what I learned about TypeScript. Long story short, Let’s take a brief look at interfaces.

1. What’s the Interface?
As JavaScript developers, especially those who write TypeScript, we use the objects to group data and pass it around. In the TypeScript world, there are two ways to achieve this. One of these ways is Interfaces. The Interfaces defines the syntax that any entity must adhere to. In other words, It forces developers to consider the type of properties, methods, and events when they are using it. Interfaces contain the definition of their members.
Interface as a Type
Line of explanations :
- We define interfaces using the “interface” keyword and add a name beside the interface keyword.
2/3. We could add properties in the interfaces with their type.
4. If we have an optional property in an interface, we must add the “?” prefix in front of the property name.
5. We also could add methods in the interfaces with its return type.
Difference Between Interfaces and Type Aliases:
- Declaration merging doesn’t work with type aliases, while it works properly with interfaces. Let me explain it. You can define the same interface multiple times, so its definitions will be merged into one.
this usage doesn’t work with type aliases because the type is a unique type unit.