Closed achingbrain closed 10 months ago
Actually it looks like passing a promise-returning function to just-debounce-it
can result in unhandled promise rejections since the function is invoked here and there's no way to await
or .catch
on the return value:
I think it's better to just use p-debounce instead of just-debounce-it
.
I have an async function I'd like to debounce while using the
wait
parameter:This causes TypeScript to become deeply upset:
The types for this function are:
Because I pass a function and a number, the third signature is selected which wants the return type of the passed function to be
void
, which it isn't, it'sPromise<void>
.To fix this, the third signature could be changed to either:
or:
Though I'm not sure why
((...args: ArgumentTypes<T>) => void) & MethodTypes
was used instead ofT & MethodTypes
in the first place?