I’m developing backend application in typescript. I want to define shape of an object. From typescript, I have options like classes, interfaces, types. Which one should I use?
Below are the docs recommending interfaces to define shapes.
The below document says, its better to use interface on types
they recommend using interfaces to define the shape of an object. But, we can’t instantiate an interface, and interfaces cannot hold data.
On the other hand, we have classes that define shape/blueprint of the object and can hold data.
So, should I go with classes to define shape and initialize it where ever I want?
where exactly should I user interfaces then, considering classes do all the work? What is the use-case of interfaces?
Please help me.