class foo {
customAdd?: (foo: unknown) => this
constructor(customAdd?: (foo: unknown) => this) { // A 'this' type is available only in a non-static member of a class or interface.
this.customAdd = customAdd
}
add(foo: unknown): this {
if (this.customAdd) {
return this.customAdd(direction);
}
// default add
}
}
foo have children classes, so this might refer to it's children but not itself, and I don't an as is a proper solution.