Dmytro Morar
TypeScript

Extends and implements

extends inherits implementation, implements enforces a contract.

extends

class Animal {
  move() {
    console.log("Moving...");
  }
}
class Dog extends Animal {
  bark() {
    console.log("Woof!");
  }
}

implements

interface Flyable {
  fly(): void;
}
class Bird implements Flyable {
  fly() {
    console.log("Flying...");
  }
}

Together

class Eagle extends Bird implements Flyable {
  fly() {
    console.log("Soaring high...");
  }
}

On this page