Open utterances-bot opened 1 year ago
Interesting! So can Interface can only be used for objects, but Type cannot be used for objects?
@Chektinchan I've spent some time learning more on a topic and I think the ts documentation nails my whole blog post in 2 senteces.
Type aliases and interfaces are very similar, and in many cases you can choose between them freely. Almost all features of an
interface
are available intype
, the key distinction is that a type cannot be re-opened to add new properties vs an interface which is always extendable.
@ummahusla And even though you can always use ‘&’ sign to extend a type with new properties :)
Types vs Interfaces in TypeScript | Edvins Antonovs
Learn key differences between types and interfaces in TypeScript
https://edvins.io/types-vs-interfaces-in-typescript