Is is possible in typescript to define an interface that will only be applied to methods that starts with a certain word and cause them to have a certain return type? I thought of something like:
interface IPattern {
[k: 'handle' + string]?: () => SomeClass
}
So that a class that implements IPatten and have methods that start with handle would be force to return a SomeClass object, while other methods would not, example:
class ForcedClass implements IPattern{
foo(): number; // ok
handleFoo(): SomeClass; // ok
handleBar(): number; // error
}
I know a could use an abstract class with all the method that I need, but since the combination of handle + something is used in a lot of different implementations, it would be verbose to create an abstract to each of them;