I am part of a team responsible for maintaining a unique JavaScript library that generates spy functions. These spy functions are designed to allow users to monitor how a function is called, primarily used in the context of unit testing.
Our library creates specialized functions with additional properties that enable users to analyze the calls made to them.
We are currently exploring the possibility of creating an innovative TypeScript definition that would enable us to pass these specialized functions into methods requiring a standard function while also retaining their extra properties.
While the following code snippet is not valid, it showcases our vision:
class Spy extends function {
wasCalled: () => boolean;
...
}
Implementing this concept would empower me to seamlessly integrate a spy into a function with the following signature:
function subjectUnderTest(callback:() => void) {
...
}