You can override a method in Typescript by creating a new method inside the inheriting class with the same name as that of the parent method. This way you can replace the original method declared in the parent class with the new method inside the child class.

class Animal {
  kingdom() {
    console.log("I belong to Animal Kingdom");
  }
}

class Dog extends Animal {}

In the above example, class Dog inherits from class Animal. The Animal class contains a method kingdom() which is made available to Dog objects due to inheritance.

let dog = new Dog();

dog.kingdom(); // I belong to Animal Kingdom

Now, if we want to override the kingdom() method in the Dog class, we can do so by adding a new method inside the Dog class with the same name.

class Animal {
  kingdom() {
    console.log("I belong to Animal Kingdom");
  }
}

class Dog extends Animal {
  kingdom() {
    //This method overrides Amimal class kingdom()
    console.log("I am a Dog!");
  }
}

let dog = new Dog();

dog.kingdom(); // I am a Dog!

As you can see, the kingdom() method inside the class Dog gets called instead of the kingdom() method of the Animal class.