I Want to parse a class to get a list of all the members declared in this class. So:
given:
class MyClass {
someMethod(){
console.log('someMethod');
}
someOtherMethod(){}
}
/// this does not work
function Debuggable(constructor: Function) {
console.warn('Debuggable called', constructor)
for (let prop in constructor.prototype) {
console.warn('prop', prop);
}
console.warn('key', Object.keys(constructor.prototype));
}
I need to be able to call Debuggable(MyClass)
and get an array with ['someMethod','someOtherMethod' ]
.
Is this possible?
As final goal I want to create a typescript decorator that calls a function before call a method inside an instance of that class.