index.ts173 chars16 linesIn the above example, IParent is an interface of interfaces. It has a property called child which is of type IChild, and IChild has a property called toys which is an array of IToy objects.
To use these interfaces, you can create an object like this:
index.ts194 chars11 linesYou can also use declaration merging to add more properties to an existing interface like so:
index.ts494 chars33 linesIn the above example, we first define gender property for IParent, IChild, and IToy interfaces. Then, we use declaration merging to add gender property to IChild interface and merge it with IParent child property. We also add price property to IToy interface. Finally, we create an object parent using these interfaces with additional gender and price properties added.
gistlibby LogSnag