antonioru / beautiful-react-hooks

🔥 A collection of beautiful and (hopefully) useful React hooks to speed-up your components and hooks development 🔥

Home Page:https://antonioru.github.io/beautiful-react-hooks/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typing for `useTimeout` is incorrect

icopp opened this issue · comments

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.

commented

@icopp this should've been fixed by super fast @playerony in version 3.6.2

Check #375