Inheritance in TypeScript Part-8

In our previous post we have overview about constructor in Type Script.Today we will learn about Inheritance.


Inheritance is object oriented programming language’s one kind of patter which makes relationship between different class but common type. This relationship is called IS-A Relationship.


Fig: Inheritance relationship between tow class

Base Class:

Sub Class:

Let’s get explain about code:


Base class is PermanentEmployee.


Constructor have two parameters.Once is firstName and Other once is lastName. Both are assigned to attributes.

Two method, Once is GetFullName

Other once is GetReverseName

Sub class is TemporaryEmployee.

Here TemporaryEmployee class  Inhered PermanentEmployee class using extends keyword.Now we can access PermanentEmployee.



Constructor taken tow parameters.  Parameters values are assigned Basic class’s constructor using super keyword.

TemporaryEmployee class’s object created

created object employeeobj then passing two attributes for constructor.

Interesting think here,

We can access GetFullName and GetReverseName in sub class (TemporaryEmployee). These were base class(PermanentEmployee).Now we can access these in sub class (TemporaryEmployee)  for IS-A Relationship.


Happy coding  🙂


Leave a Reply

Your email address will not be published. Required fields are marked *