I'm attempting to log when a method is automatically called. (I found the code snippet on )
augment(withFn) {
let name, fn;
for (name in window) {
fn = window[name];
if (typeof fn === 'function') {
window[name] = (function(n, f) { // An error is occurring here.
const args = arguments;
return function() {
withFn.apply(this, args);
return fn.apply(this, arguments);
};
})(name, fn);
}
}
}
and then call this.
this.augment(function(name, fn) {
console.log('calling ' + name);
});
An error is being thrown:
ERROR in src/app/app.component.ts(81,17): error TS2740: Type '() => any' is missing the following properties from type 'Window': Blob, TextDecoder, TextEncoder, URL, and 232 more.
I'm wondering how I can override a window function?