Easy learning with example program codes

typescript interface inheritance tutorial

TypeScript interface:

An interface is declared with interface keyword. It is a way of implementing 100% abstraction. It only contains the declaration of the members. Interface forms a contract with your class that force your class to have all methods defined by the interface must appear in the class.

TypeScript provides the facility of inheritance between interfaces i.e. an interface can inherit other interface. We have to use extends keyword to implement inheritance among interfaces.


ChildInterfaceName extends SuperInterfaceName


interface Person { 
interface Employee extends Person { 
var engineer = <Employee>{}; 
engineer.age = 30; = "Jai";
engineer.empId = "EMP024";
console.log("Name:  ";
console.log("Age:  "+engineer.age);
console.log("Emp Id:  "+engineer.empId);

Try it:

JS Bin on

Please follow and like us:

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki