Grokking TypeScript
0% completed
Type Aliases vs Interfaces
If type and interface can both describe the same object, why does TypeScript have two keywords? The answer is that their overlap is only partial. An interface always describes an object, while a type alias can name any type at all, and each one has a few abilities the other lacks.
What a Type Alias Is
A type alias gives a name to a type. It does not create a new type, because the name simply stands for the type on the right side of the equals sign. For an object, the result behaves as the User interface does.
type User = { name: string; age: number; };
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%