If a class does not implement a method, I want to handle the error raised and inject my own code, using the method name.
For example:
class Foo {
def method_missing(methodName) {
console.log(`${methodName} was called`);
}
}
let foo = new Foo();
foo.bar(); // should print 'bar was called' in the console
In ruby, there is a method called method_missing on every class that provides this behavior. Can we get this in typescript, and how?
No, TypeScript cannot do this.