mattpocock / ts-error-translator

VSCode extension to turn TypeScript errors into plain English
https://ts-error-translator.vercel.app
2.37k stars 91 forks source link

Translation request for 7019 #276

Open toduyemi opened 6 months ago

toduyemi commented 6 months ago

Error Text

Rest parameter 'args' implicitly has an 'any[]' type.

Supporting Information

Please provide other information which led to this error, and any specific questions you have about it:

I'm really struggling with this error and haven't been able to find anything on how to resolve it. How do you type for rest parameter?

function debouncePromise<T>(fn: (a: T[]) => Promise<T>, time: number) {
  let timerId: ReturnType<typeof setTimeout> | undefined = undefined;

  return function debounced(...args) {
    if (timerId) {
      clearTimeout(timerId);
    }
    return new Promise((resolve) => {
      timerId = setTimeout(() => resolve(fn(...args)), time);
    });
  };
}