From 4b706b583795b9d5444c247d78bf0e3979348400 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Thu, 26 Oct 2023 20:14:41 +1100 Subject: [PATCH] fix use debounced call --- .../flow_v0.83.x-/test_use-debounce_v9.x.x.js | 12 ++++++++++-- .../flow_v0.83.x-/use-debounce_v9.x.x.js | 5 +---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/definitions/npm/use-debounce_v9.x.x/flow_v0.83.x-/test_use-debounce_v9.x.x.js b/definitions/npm/use-debounce_v9.x.x/flow_v0.83.x-/test_use-debounce_v9.x.x.js index 2ef45ff641..a5784d57fe 100644 --- a/definitions/npm/use-debounce_v9.x.x/flow_v0.83.x-/test_use-debounce_v9.x.x.js +++ b/definitions/npm/use-debounce_v9.x.x/flow_v0.83.x-/test_use-debounce_v9.x.x.js @@ -31,11 +31,15 @@ describe('use-debounce', () => { 1000 ); + debounced('test'); + // $FlowExpectedError[incompatible-call] it matches the type of the callback + debounced(123); + debounced.cancel(); debounced.flush(); debounced.isPending(); - // $FlowExpectedError[prop-missing] + // $FlowExpectedError[incompatible-call] debounced.foo(); }); @@ -51,11 +55,15 @@ describe('use-debounce', () => { 1000 ); + debounced('test'); + // $FlowExpectedError[incompatible-call] it matches the type of the callback + debounced(123); + debounced.cancel(); debounced.flush(); debounced.isPending(); - // $FlowExpectedError[prop-missing] + // $FlowExpectedError[incompatible-call] debounced.foo(); }); }); diff --git a/definitions/npm/use-debounce_v9.x.x/flow_v0.83.x-/use-debounce_v9.x.x.js b/definitions/npm/use-debounce_v9.x.x/flow_v0.83.x-/use-debounce_v9.x.x.js index 962c34b6ef..ae01c99028 100644 --- a/definitions/npm/use-debounce_v9.x.x/flow_v0.83.x-/use-debounce_v9.x.x.js +++ b/definitions/npm/use-debounce_v9.x.x/flow_v0.83.x-/use-debounce_v9.x.x.js @@ -37,10 +37,7 @@ declare module 'use-debounce' { * 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> = {| - ...ControlFunctions, - (...args: Parameters): R | void, - |}; + declare type DebouncedState R> = ControlFunctions & ((...args: Parameters) => R | void); declare module.exports: {| useDebounce: (value: T, delay: number, options?: {|