How could I have "this.foo" as "Foo" in "Bar" class ?
abstract class AFoo {}
abstract class ABar {
constructor(protected foo: AFoo) {}
}
class Foo extends AFoo {
echoTest() {
return 'test';
};
}
class Bar extends ABar {
constructor(foo: Foo) {
super(foo)
}
write() {
//Actually this line don't work cause this.foo is of AFoo type
return this.foo.echoTest();
//I want to avoid casting like this
//(<Foo>this.foo).echoTest();
}
}
Expected the overloading of the constructor to induce the child type to the class