I came across a library that contains the following class:
class Dog {
public run(speed: number, movement: number): void;
public run(speed: number, type: string): void;
public run(speed: number, opts: string | number): void {
// performing some actions here
}
}
My aim is to develop another interface with a different method name but matching the exact signature of Dog.run
. I attempted the following approach, however, it failed as I couldn't reference the run
method within Dog
by using Dog.run
:
interface SpecialDog {
runWithSpecialPower: (...args: Parameters<Dog.run>) => ReturnType<Dog.run>
}
In this scenario, I cannot simply extend SpecialDog
from Dog
because I prefer the method name to be runWithSpecialPower
rather than just run
. Is there any way for me to duplicate the method signature of another method?