Posted under TypeScript
Permalink
Tags Angular, Tip
I was looking into this in order to find the best type for an arbitrary stream of Json.
This comment post here has an interesting discussion on this, and concludes that any is the most flexible, and there aren’t strong reasons for using the Object or {} (which are similar, as {} extends Object).
This post describes how to use TypeScript interfaces to describe the Json.
http://json2ts.com is a site that automatically creates the interfaces from the json for you, however in my case it did nothing when I gave it a returned CouchDB Json stream.
This stackoverflow post also discusses the issue and mentions json2ts.com – the poster evidently had more luck with it than I did.
Leave a Reply
You must be logged in to post a comment.