I'm having an error in the function below:
export const throttle = (func: Function, limit: number) => {
let inThrottle: boolean;
return function () {
const args = arguments;
const context = this;
if (!inThrottle) {
func.apply(context, args);
inThrottle = true;
setTimeout(() => inThrottle = false, limit);
}
}
}
I can not pass this
to const
context
the following error appears:
[ts] 'this' implicitly has type 'any' because it does not have a type annotation.