Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. TypeScript Mastery

Lesson 18 of 56 · Typescript

Class Inheritance & Abstract Classes

Duration: 20 minutes

Inheritance

class Employee extends Person {
  private employeeId: string;
  constructor(name: string, ssn: string, birthYear: number, employeeId: string) {
    super(name, ssn, birthYear);
    this.employeeId = employeeId;
  }
  getId() { return this.employeeId; }
}

Abstract Classes

abstract class Shape {
  abstract area(): number; // must be implemented by subclasses
}

class Circle extends Shape {
  constructor(public radius: number) { super(); }
  area() { return Math.PI * this.radius ** 2; }
}

instanceof Checks

function isShape(x: any): x is Shape {
  return x instanceof Shape;
}

Info

Abstract classes are useful when you need shared implementation plus enforced contract.

Previous: Classes – Public, Private, ProtectedNext: Accessors (get/set) & Readonly Properties