Skip to content

Commit e212409

Browse files
Merge pull request #232 from Xeonian/experimental-hooks-ts-symbols
Add experimental hook declarations to index.d.ts
2 parents 6a24471 + de0bfaf commit e212409

File tree

1 file changed

+68
-8
lines changed

1 file changed

+68
-8
lines changed

index.d.ts

+68-8
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,34 @@ declare module "@uidotdev/usehooks" {
127127
(value: string) => Promise<void>
128128
];
129129

130+
export function useContinuousRetry(
131+
callback: () => any,
132+
interval?: number,
133+
options?: {
134+
maxRetries?: number
135+
}): boolean;
136+
137+
export function useCountdown(endTime: number, options: {
138+
interval: number,
139+
onComplete: () => any,
140+
onTick: () => any
141+
}): number;
142+
130143
export function useCounter(
131144
startingValue?: number,
132145
options?: {
133146
min?: number;
134147
max?: number;
135148
}
136149
): [
137-
number,
138-
{
139-
increment: () => void;
140-
decrement: () => void;
141-
set: (nextCount: number) => void;
142-
reset: () => void;
143-
}
144-
];
150+
number,
151+
{
152+
increment: () => void;
153+
decrement: () => void;
154+
set: (nextCount: number) => void;
155+
reset: () => void;
156+
}
157+
];
145158

146159
export function useDebounce<T>(value: T, delay: number): T;
147160

@@ -152,8 +165,25 @@ declare module "@uidotdev/usehooks" {
152165

153166
export function useDocumentTitle(title: string): void;
154167

168+
export function useEventListener(
169+
target: React.MutableRefObject<Element> | Element,
170+
eventName: string,
171+
handler: (Event) => any,
172+
options?: {
173+
capture?: boolean,
174+
passive?: boolean,
175+
once?: boolean
176+
}): void;
177+
155178
export function useFavicon(url: string): void;
156179

180+
export function useFetch(
181+
url: string,
182+
options?: {}): {
183+
error: Error | undefined,
184+
data: any | undefined
185+
}
186+
157187
export function useGeolocation(options?: PositionOptions): GeolocationState;
158188

159189
export function useHistoryState<T>(initialPresent?: T): HistoryState<T>;
@@ -169,14 +199,35 @@ declare module "@uidotdev/usehooks" {
169199
options?: IntersectionObserverInit
170200
): [React.MutableRefObject<Element>, IntersectionObserverEntry | null];
171201

202+
export function useInterval(cb: () => any, ms: number): () => void;
203+
204+
export function useIntervalWhen(
205+
cb: () => any,
206+
options: {
207+
ms: number,
208+
when: boolean,
209+
startImmediately?: boolean
210+
}): () => void;
211+
172212
export function useIsClient(): boolean;
173213

174214
export function useIsFirstRender(): boolean;
175215

216+
export function useKeyPress(
217+
key: string,
218+
cb: (Event) => any,
219+
options?: {
220+
event?: string,
221+
target?: Element | Window,
222+
eventOptions?: {}
223+
}): void;
224+
176225
export function useList<T>(defaultList?: T[]): [T[], CustomList<T>];
177226

178227
export function useLockBodyScroll(): void;
179228

229+
export function useLogger(name: string, ...rest: any[]): void;
230+
180231
export function useLongPress(
181232
callback: (e: Event) => void,
182233
options?: LongPressOptions
@@ -208,12 +259,19 @@ declare module "@uidotdev/usehooks" {
208259
type: string;
209260
};
210261

262+
export function usePageLeave(cb: () => any): void;
263+
211264
export function usePreferredLanguage(): string;
212265

213266
export function usePrevious<T>(newValue: T): T;
214267

215268
export function useQueue<T>(initialValue?: T[]): CustomQueue<T>;
216269

270+
export function useRandomInterval(cb: () => any, options: {
271+
minDelay: number,
272+
maxDelay: number
273+
}): () => void;
274+
217275
export function useRenderCount(): number;
218276

219277
export function useRenderInfo(name?: string): RenderInfo | undefined;
@@ -231,6 +289,8 @@ declare module "@uidotdev/usehooks" {
231289

232290
export function useThrottle<T>(value: T, delay: number): T;
233291

292+
export function useTimeout(cb: () => any, ms: number): () => void;
293+
234294
export function useToggle(
235295
initialValue?: boolean
236296
): [boolean, (newValue?: boolean) => void];

0 commit comments

Comments
 (0)