Please look at this code:
class Greeter {
greeting: string;
constructor(message: string) {
this.greeting = message;
}
greet() {
return "Hello, " + this.greeting;
}
}
class Ge extends Greeter {
constructor(message: string) {
super(message);
}
greet() {
return "walla " + super.greet();
}
}
let greeter = new Ge("world");
console.log(greeter.greet());
console.log((<Greeter> greeter).greet()); // walla Hello, world
I expect the second magazine to print Hello, world. Looking at the code passed Javascript, I see the same command so that this is not a surprise.
The real question is: how do you add greeterto your extended class?
johni source
share