Inheritance

Inheritance is another paradigm that is one of the cornerstones of object-oriented programming. Inheritance means that an object uses another object as its base type, thereby inheriting all of the base object's characteristics. In other words, all of the base object's properties and functions. Both interfaces and classes can use inheritance. An interface or class that is inherited from is known as the base interface, or base class, and the interface or class that does the inheritance is known as the derived interface, or derived class. TypeScript implements inheritance using the extends keyword.

Interface inheritance

As an example of interface inheritance, consider the following TypeScript code:

 interface IBase { id: number; } interface ...

Get Mastering TypeScript - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.