TypeScript Interfaces vs Types
what should you use to define the structure of your object? should you use interface or type alias?
I have been using TypeScript for a month now, to be honest at first I was annoyed by the ugly long syntax, eventually, it made a lot of sense. I started enjoying the feature it offers. I'm in a love and hate relationship with typescript. I might revisit this article. this is for my future reference.
what should you use to define the structure of your object? should you use interface or type alias?
both are used to do the same thing, then why do they exist?
spoiler alert- it doesn't matter. there are preferences you can have for each one and there are some concrete changes in their behavior, as ts mature over years the features that interfaces and types offer are gotten more and more similar. if you ask me what I use? I personally prefer to use the interface whenever possible.
interfaces are geared towards defining the shape of the objects, classes, or functions, well the syntax for the function is quite awkward
when I'm not dealing with the objects I prefer type. that's the short answer for what I use.
if both offer similar functionalities? what is the difference?
as I mentioned interfaces are built to define the shape of the objects

This is checking the type as expected, what if I miss anything?

this clearly tells that hungry is missing.
just like class inheritance we can also inherit interface properties by using extends.

now we can try to replace type of me from person to additional info.

one of the unique features of the interface is extending. wait there is one more thing called declaration merging.
what declaration merging does is that when you have the interface with the same name, ts automatically merge.

let's see if I remove isHungry property-

see, there is no difference at all.
we can use unions here-

so the object type can be either person or Engineer.
what to use? on the typescript documentation page, they suggest us to use interfaces whenever possible. it's better to use interfaces wherein you can extend and change the needs to fit your requirements.
Types are static and large, they are just an alias to a shape and you can make a new type by using unions and intersections but you can't change the type itself.
so my understanding is that if you are working with objects or classes, use interface, I guess this will cover most of your use cases.
if you are not using objects or classes the use type. using interfaces for functions makes your code look a little awkward.
Maybe you can discuss with your team what to use. make sure you maintain consistency throughout.