From 9225e005d7a04bc697fccb8e7f497cdce0f75325 Mon Sep 17 00:00:00 2001 From: Mikhail Gorbachev Date: Mon, 23 May 2022 13:35:48 +0300 Subject: [PATCH] Throttle typings added (#1826) Signed-off-by: Mikhail Gorbachev --- package.json | 1 + src/utils/observe-dimensions.ts | 4 ++-- yarn.lock | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7fb0714cb8..f5c0a2c5cb 100644 --- a/package.json +++ b/package.json @@ -115,6 +115,7 @@ "@types/lodash.get": "^4.4.6", "@types/lodash.isequal": "^4.5.5", "@types/lodash.pick": "^4.4.6", + "@types/lodash.throttle": "^4.1.7", "@types/lodash.uniq": "^4.5.7", "@types/lodash.uniqby": "^4.7.7", "@types/lodash.xor": "^4.5.7", diff --git a/src/utils/observe-dimensions.ts b/src/utils/observe-dimensions.ts index f2adadd6fe..e964094b51 100644 --- a/src/utils/observe-dimensions.ts +++ b/src/utils/observe-dimensions.ts @@ -59,7 +59,7 @@ function getObserverRegistry() { export function observeDimensions( target: Element, - handleResize: (size: Dimensions) => void, + handleResize: (size: Dimensions | null) => void, throttleDelay = DEFAULT_THROTTLE_DELAY ) { const registry = getObserverRegistry(); @@ -72,7 +72,7 @@ export function unobserveDimensions(target: Element) { registry.unsubscribe(target); } -function getSize(node, entry) { +function getSize(node, entry): Dimensions | null { if (entry.contentRect) { const {width, height} = entry.contentRect; return {width, height}; diff --git a/yarn.lock b/yarn.lock index 7bdc0e6589..c7fa91d81b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3324,6 +3324,13 @@ dependencies: "@types/lodash" "*" +"@types/lodash.throttle@^4.1.7": + version "4.1.7" + resolved "https://registry.yarnpkg.com/@types/lodash.throttle/-/lodash.throttle-4.1.7.tgz#4ef379eb4f778068022310ef166625f420b6ba58" + integrity sha512-znwGDpjCHQ4FpLLx19w4OXDqq8+OvREa05H89obtSyXyOFKL3dDjCslsmfBz0T2FU8dmf5Wx1QvogbINiGIu9g== + dependencies: + "@types/lodash" "*" + "@types/lodash.uniq@^4.5.7": version "4.5.7" resolved "https://registry.yarnpkg.com/@types/lodash.uniq/-/lodash.uniq-4.5.7.tgz#0773960ec0148b29e6a54821a65b878a0ebb5c1a"