Easy learning with example program codes

typescript class inheritance tutorial

TypeScript Class:

As we discussed in earlier tutorials that TypeScript supports object-oriented programming concepts like classes, interfaces, etc. Class is act as a blue print or template for creating objects. It provides state and behaviour for its objects. A class is used to encapsulate the data for the object.

TypeScript Inheritance:

Inheritance is a way to implement IS-A relationship i.e. parent child relationship. Subclass inherits the super class properties like data member, methods. Inheritance is the way of re-usability of code. Let us take the example of parent and child. A child inherits the properties of its parent.

Why inheritance is used?

  • Code re-usability.
  • Run-time polymorphism.


class subclass extends superclass{
   //subclass code


class Employee { 
   constructor(name:string) { = name;
class Engineer extends Employee { 
   display():void { 
      console.log("Name:  ";
var obj = new Engineer("Jai"); 

Try it:

JS Bin on

Please follow and like us:

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki