Answer the question
In order to leave comments, you need to log in
Why is the type of the child class not compatible with the parent, can't be assigned this?
Good afternoon, I still could not figure out the polymorphic this and why child classes are incompatible with parent classes at some points:
class A {
parent: A;
constructor(parent: A) {
this.parent = parent;
}
}
class B extends A {
getParent(): this { // ERROR
return this.parent; // ERROR
}
}
A
polymorphic type this
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question