title: How to call base class methods in typescript
body: <p>I expected it to call the Animal class method, not Snake.</p>
  
  <p>What actually happens when I do a casting? <code>typescript &lt;Class&gt;object</code></p>
  
  <pre class="lang-js prettyprint-override"><code>
  class Animal {
      name: string;
      constructor(theName: string) {
          this.name = theName;
          this.toString();
          console.log(`\tis Animal?: ${this instanceof Animal}`);
          console.log(`\tis Snake?:  ${this instanceof Snake}`);
          console.log(`\tis Horse?:  ${this instanceof Horse}`);
          console.log()
      }
  
      toString() {
          console.log(`My name is ${this.name} and I'm a animal`);
      }
  }
  
  class Snake extends Animal {
      name: string;
  
      constructor(nameAnimal: string, nameSnake: string) {
          super(nameAnimal);
          this.name = nameSnake;
      }
  
      toString() {
          console.log(`My name is ${this.name} and I'm a snake`);
      }
  }
  
  class Horse extends Animal {
      constructor(name: string) {
          super(name);
      }
  }
  
  // create my objects
  let sammy = new Snake('Sammy the Python', 'sssssamy');
  let tommy: Animal = new Horse('Tommy the Palomino');
  
  
  // using method of snake
  sammy.toString();
  
  // casting 
  const animal: Animal = (&lt;Animal&gt;sammy); // or const animal: Animal =  sammy as Animal;
  
  // using method of animal
  animal.toString()
  
  </code></pre>
  
  <p>EDIT: 
  fixed output
  Output:</p>
  
  <pre><code>My name is Sammy the Python and I'm a snake
          is Animal?: true
          is Snake?:  true
          is Horse?:  false
  
  My name is Tommy the Palomino and I'm a animal
          is Animal?: true
          is Snake?:  false
          is Horse?:  true
  
  My name is sssssamy and I'm a snake 
  
  My name is sssssamy and I'm a snake
  </code></pre>
  
  <p>In which case, I would not have to print My name is ssssamy and I'm an animal?
  I think overload method, and the methods in base should to be called, because I used the casting in snake.  </p>