Typing for `useTimeout` is incorrect
icopp opened this issue · comments
Ian Copp commented
It looks like the typing for useTimeout
is wrong and should return an array literal instead. This way it gets proper type inference when destructuring the array.
Here is the diff that solved my problem:
diff --git a/node_modules/beautiful-react-hooks/useTimeout.d.ts b/node_modules/beautiful-react-hooks/useTimeout.d.ts
index 383d9b6..ecaa671 100644
--- a/node_modules/beautiful-react-hooks/useTimeout.d.ts
+++ b/node_modules/beautiful-react-hooks/useTimeout.d.ts
@@ -6,5 +6,5 @@ export declare type UseTimeoutOptions = {
* An async-utility hook that accepts a callback function and a delay time (in milliseconds), then delays the
* execution of the given function by the defined time.
*/
-declare const useTimeout: <TCallback extends GenericFunction>(fn: TCallback, milliseconds: number, options?: UseTimeoutOptions) => (boolean | (() => void))[];
+declare const useTimeout: <TCallback extends GenericFunction>(fn: TCallback, milliseconds: number, options?: UseTimeoutOptions) => [boolean, () => void];
export default useTimeout;
This issue body was partially generated by patch-package.
Rù commented
@icopp this should've been fixed by super fast @playerony in version 3.6.2
Check #375