Avatar ·

Can you extend types in TypeScript like interfaces?

Hi everyone! I just started learning TypeScript and ran into some confusion. I know that interfaces can be extended using `extends`. For example: ```typescript interface User { name: string; } interface AdminUser extends User { role: string; } ``` This works perfectly. But when I try to do the same with types (type alias), it doesn't work: ```typescript type User = { name: string; }; type AdminUser extends User { // ❌ Error: 'extends' doesn't work with types role: string; } ``` I've tried different approaches, but TypeScript complains. Online sources say types can be extended using intersections (&), but I don't fully understand how to do it correctly and what the difference is between interfaces and types in the context of extension. Please advise.