If you are using an interface to define a shape/schema for some data and you are creating Object literals to represent that data — Why not use a class? You get a constructor, you can validate the input, you can overload the constructor, you can use getters/setters, the class can inherit from a base class and also implement multiple interfaces? Is it really an interface, if nothing ever implements it? My thoughts on this are more from a C#/Java/.NET usage of interfaces and the OOP definitions.

I know it is a common practice in TypeScript/JS apps to use this technique to define shapes. I just prefer a class especially when you have to create an object with that data shape. There is nothing wrong with instantiating a class — Object literals work, but I prefer classes.


I love tacos, code, jazz, my husky and maybe 3 people in this world...and of course: Angular. Angularlicious podcast — more info at www.AngularArchitecture.com

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store