I'd like to know if there's a way to modify a function in TypeScript and access the original function within. This is an example of how I got it to work:
let obj = {
shout: () => {
console.log("AHHHHH!");
},
};
let s = obj.shout;
obj.shout = () => {
console.log("I'm going to shout.");
s();
};
obj.shout(); //-> "I'm going to shout", "AHHHHH!"
This way I was able to add a warning to my shout function whenever it's called - but I feel like that's an ugly way to do it, so I wonder if there's a better way.