Skip to Content
Learning TypeScript 2.x - Second Edition
book

Learning TypeScript 2.x - Second Edition

by Remo H. Jansen
April 2018
Beginner content levelBeginner
536 pages
13h 21m
English
Packt Publishing
Content preview from Learning TypeScript 2.x - Second Edition

Depth of the inheritance tree (DIT)

We can also declare a new class that inherits from a class, which is already inheriting from another class. In the following code snippet, we declare a class called SchoolPrincipal that extends the Teacher class, which extends the Person class:

class SchoolPrincipal extends Teacher { 
    public manageTeachers() { 
        return console.log( 
            `We need to help our students!` 
        ); 
    } 
} 

If we create an instance of the SchoolPrincipal class, we will be able to access all the properties and methods from its parent classes (SchoolPrincipal, Teacher, and Person):

const principal = new SchoolPrincipal( "Remo", "Jansen", "remo.jansen@wolksoftware.com" ); principal.greet(); // "Hi!" principal.teach(); // "Welcome to class!" principal.manageTeachers(); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering TypeScript - Fourth Edition

Mastering TypeScript - Fourth Edition

Nathan Rozentals
Learning TypeScript

Learning TypeScript

Josh Goldberg
TypeScript for Beginners

TypeScript for Beginners

Bharath Thippireddy

Publisher Resources

ISBN: 9781788391474Supplemental Content