Closed
Description
TypeScript Version: 4.0.2
Search Terms: mixins, inheritance
Code
type Mixable = new (...args: any[]) => {};
class Base {
constructor(protected _a: string, protected _b: string) {}
}
const A = (Base: Mixable) => class A extends Base {
a() {
console.log(this._a);
return this;
}
};
const B = (Base: Mixable) => class B extends Base {
b() {
console.log(this._b);
return this;
}
};
const C = A(B(Base));
const o = new C("a","b");
o.a().b();
Expected behavior: The compiler should be able to identify the properties shared among mixins, and should not emit any error.
Actual behavior: TypeScript emit errors that it does not able to identify the shared properties, and also failed to chain methods.
Playground Link: https://bit.ly/34q5ueS
Note: If you run this, it runs successfully, and generates the expected output without any JS error.