I am trying to use multiple class by extending in interface. using typescript, but getting this error:
[ERR]: employee.eat is not a function
here is my try:
class Animal {
species: string;
id: number = 0;
constructor(species: string) {
this.species = species
}
eat(fruit:string):void{
console.log('eating is healty' + fruit)
}
}
class Person {
name: string;
id: number = 0;
constructor(name: string) {
this.name = name
}
speak(){
console.log(this.name + this.id);
}
}
interface Employee extends Person, Animal {
employeeCode: string;
}
class Employee implements Employee {
constructor(){
}
}
let employee: Employee = new Employee();
employee.eat('apple');