-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compose: Add types to useThrottle
and typecheck useFocusOutside
#32170
Conversation
Size Change: -15 B (0%) Total Size: 1.03 MB
ℹ️ View Unchanged
|
8974233
to
f8b93a0
Compare
* @param {TFunc} fn The function to throttle. | ||
* @param {number} [wait] The number of milliseconds to throttle invocations to. | ||
* @param {import('lodash').ThrottleSettings} [options] The options object. See linked documentation for details. | ||
* @return {TFunc & import('lodash').Cancelable} Throttled function. |
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.
Should this use DebouncedFunc
instead?
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.
Agreed, it seems like this could be a more up-to-date way of typing it:
* @return {TFunc & import('lodash').Cancelable} Throttled function. | |
* @return {import('lodash').DebouncedFunc<TFunc>} Throttled function. |
Although it seems like there isn't any DebouncedFunc
export, at least in the version of lodash
that is being used. DebouncedFunc
was introduced almost a year ago
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.
Yeah I don't see DebouncedFunc
in the declarations available to us 🤔
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.
Fine to leave it as-is then 👍
f8b93a0
to
6384cf4
Compare
While @sarayourfriend is AFK I will take over this PR — I just rebased on top of @tyxla do you mind having another round of review? |
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.
LGTM 👍
@@ -19,21 +19,23 @@ | |||
"src/higher-order/with-global-events/**/*", | |||
"src/hooks/use-async-list/**/*", | |||
"src/hooks/use-constrained-tabbing/**/*", | |||
"src/hooks/use-copy-on-click/**/*", |
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.
Thanks for sorting those 👍
Description
Adds types to
useThrottle
and includesuseFocusOutside
to typechecking (it was already comprehensively typed).Part of #18838
How has this been tested?
Type checks pass. No runtime changes except for explicit arguments for
useThrottle
but the functions are equivalent.Types of changes
New feature.
Checklist:
*.native.js
files for terms that need renaming or removal).