I'm interested in finding a way to determine a method's signature. The following code represents the question I have:
class MyClass {
constructor(public foo: any){}
}
const object1 = new MyClass((): void => {
console.log('My function is to say hi. Hello!');
});
const object2 = new MyClass((n: number): void => {
console.log('My function is echo a number. Here it is: ' + n);
});
object1.foo(); // My function is to say hi. Hello!
object2.foo(15); // My function is echo a number. Here it is: 15
console.log(typeof object1.foo); // prints 'function'.
// Is there a way to print '(): void' instead?
console.log(typeof object2.foo); // prints 'function'.
// Can we print '(number): void' instead?