- Notifications
You must be signed in to change notification settings - Fork1.3k
[use-debounce] Add definition#4531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| * Subsequent calls to the debounced function `debounced.callback` return the result of the last func invocation. | ||
| * Note, that if there are no previous invocations it's mean you will get undefined. You should check it in your code properly. | ||
| */ | ||
| declare type DebouncedState<R, T: (...args: any) => R> = {| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Maybe useReturnType if you want to stay close to the TS defs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yes I had tried to follow it exactly, but when I didT: (...args: any) => ReturnType<T> it errors sayingT is undefined, I suppose as a type variableT hasn't been initialised while computing the constraint ofT.
Recreated intry flow. So I just made another genericR which at least allows it to implicitly cast into.
Let me know if you got any other suggestions :)
Closes#4526
Other notes: