antonioru / beautiful-react-hooks

šŸ”„ A collection of beautiful and (hopefully) useful React hooks to speed-up your components and hooks development šŸ”„
https://antonioru.github.io/beautiful-react-hooks/
MIT License
8.17k stars 577 forks source link

Typing for `useTimeout` is incorrect #374

Closed icopp closed 2 years ago

icopp commented 2 years ago

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.

antonioru commented 2 years ago

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

Check #375