Closed
Description
Hi, for inheritance purposes i need to type methods depending on class returned by getter, but i get 'is not assignable' error.
Is this a bug?
class S1 {}
class S2 extends S1 {}
class A {
get x() {
return S1
}
f(): InstanceType<(typeof this)["x"]> {
return new this.x as InstanceType<(typeof this)["x"]> // no error
}
fError(): InstanceType<(typeof this)["x"]> {
return new this.x // got error
}
}
class B extends A {
get x() {
return S2
}
f1(){
return this.f();
}
}
const a = new A;
const s1test = a.f() // S1 type
const b = new B;
const s2test = b.f1() // S2 type