December 2017
Beginner
372 pages
10h 32m
English
As we saw in classes, interfaces can also be extended from other interfaces. This allows us to create new custom types from existing types and make our code more reusable. When we extend an interface, the child interface automatically inherits all the properties and methods of the parent interface, much like classes. The following example shows how we can extend interfaces:
interface IArticle{ author:string; title:string;}interface IEspn extends IArticle{ description: string;}let news: IEspn = { author:"ESPN", title: "Latest news", description:"Latest ESPN news"}
To extend an interface, TypeScript provides the extends keyword followed by the interface name. As you can see in the preceding example, the IEspn interface ...
Read now
Unlock full access