"return this" from inherited method not working as expected
- Dominant language
- Rust
- Stars
- 22.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
I'm writing classes where the methods return "this" to allow for method chaining.
When the method is inherited then "return this" doesn't seem to be working as expected:
```
class A {
one() { return this; } // "this" should return the instance of "B" when inherited
}
class B extends A {
two() {}
}
const b = new B();
b.one(); // ok
b.two(); // ok
b.one().two(); // Cannot call `b.one().two` because property `two` is missing in `A`
```
On flow/try:
https://flow.org/try/#0MYGwhgzhAECC0G8BQ1oHsB2BTAFASkWgCcsAXAVyI2lIAsBLCAbmgF9oB6D6AIjsZ7QItNORAATYmUrU6WaPQwRSYDMHloAZrwBCggO60s1RUaL1SWcUlZIkoSDB3QsAD0sZxMeMlSl9aPiItrb2mMrQAEbQALzQ2PrQOvhMdpEAdJi4eCxc6ADWSBn+gTmc3GiFGVn46SUp5dAAwqoYaKTQwGAgINAABtXYtSV9UVhd5BDyAA5EaNNYRKQAnv0jCjAAtowQigDmCtR9sH12QA
Any suggestions appreciated, thanks.
Contributor guide
Assessment
This issue has not been assessed yet.