Upon exploring the code in this playground link,
abstract class Base<F extends () => void> {
public abstract __call__: F;
}
type CallSignature<T> = {
(): T;
(value: T): void;
}
class Foo<T> extends Base<CallSignature<T>> {
public __call__(): T;
public __call__(value: T) : void;
public __call__(value?: T) {
return value;
}
}
Encountering the error message:
Class 'Base<CallSignature<T>>' defines instance member property '__call__', but extended class 'Foo<T>' defines it as instance member function.(2425)
The query arises on how to clarify that __call__
within Base
is designated to be a method, while retaining its definition based on T
(thus allowing various signatures including overloads).
Please note that direct reference by Base
to CallSignature
is not permissible, as it serves as a distinct interface for each subclass (hence being passed as F
).
Furthermore, the essence of this inquiry lies in having Base
dictate the interface that Foo
must adhere to, even if Foo introduces a generic that alters this requirement in some manner.