Get sample data and put it in a .ts file:
var people = [ { "name": "bob", "height": 150, "pets": [{ "name": "spot", "species": "dog" }] }, { "name": "jane", "height": 142, "pets": [{ "name": "lucy", "species": "cat" }] } ];
Run tsc --declaration yourFile.ts
You will now have yourFile.d.ts :
declare var people: { "name": string; "height": number; "pets": { "name": string; "species": string; }[]; }[];
Replace declare var people: with interface Person , remove the trailing [] and (optionally) remove the quotation marks:
interface Person { name: string; height: number; pets: { name: string; species: string; }[]; }
source share