Can you advise on the proper way to write this class?
class X {
f(): this {
return this;
}
g(): { a: this } {
return { a: this };
}
h(obj: {a: this}): this {
return obj.a;
}
}
Issue encountered in ts playground:
A 'this' type is available only in a non-static member of a class or interface.
I could simply use X
as the type, but I intend for these methods to correctly infer the type when X
extends another parent class and when another child class extends X
.