⊗tsSpOpInh 7 of 37 menu

OOP Class Inheritance in TypeScript

Class inheritance in TypeScript works in the usual way, just like in plain JavaScript.

Let's try. Let's say we have the following class:

class User { name: string; constructor(name: string) { this.name = name; } }

Let's inherit from this class:

class Student extends User { course: number; constructor(name: string, course: number) { super(name); this.course = course; } }

Create a class Employee that inherits from the class User.

bydeenesfrptru