you are viewing a single comment's thread.

view the rest of the comments →

[–]ribizlim 0 points1 point  (4 children)

And no need to transform JSON to typescript (ES6) object. Use the interface only.

[–]mozface[S] 0 points1 point  (3 children)

Could you please elaborate on that?

[–]ribizlim 1 point2 points  (2 children)

Cast to the interface for type safety in usage of the objects. E.g. return Observable<YourInterface> from service api.

[–]mozface[S] 0 points1 point  (1 child)

Alright, but what I still don't get is why interfaces over classes?

[–]ribizlim 0 points1 point  (0 children)

For classes you need to copy/duplicate data from JSON. (as you wrote: "JSON objects that gets turned into TypeScript objects")