From 97acffafcc75676330d7939a94930001614fe975 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Tue, 7 May 2024 16:32:19 +0200 Subject: [PATCH] fix useStateFromStores JSDoc Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com> --- src/webpack/common/stores.ts | 14 +++----------- src/webpack/common/types/stores.d.ts | 7 +++++++ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/webpack/common/stores.ts b/src/webpack/common/stores.ts index 2f9786bc5..be5721ff3 100644 --- a/src/webpack/common/stores.ts +++ b/src/webpack/common/stores.ts @@ -64,23 +64,15 @@ export let DraftStore: t.DraftStore; /** * React hook that returns stateful data for one or more stores * You might need a custom comparator (4th argument) if your store data is an object - * * @param stores The stores to listen to * @param mapper A function that returns the data you need - * @param idk some thing, idk just pass null + * @param dependencies An array of reactive values which the hook depends on. Use this if your mapper or equality function depends on the value of another hook * @param isEqual A custom comparator for the data returned by mapper * * @example const user = useStateFromStores([UserStore], () => UserStore.getCurrentUser(), null, (old, current) => old.id === current.id); */ -export const { useStateFromStores }: { - useStateFromStores: ( - stores: t.FluxStore[], - mapper: () => T, - idk?: any, - isEqual?: (old: T, newer: T) => boolean - ) => T; -} - = findByPropsLazy("useStateFromStores"); +// eslint-disable-next-line prefer-destructuring +export const useStateFromStores: t.useStateFromStores = findByPropsLazy("useStateFromStores").useStateFromStores; waitForStore("DraftStore", s => DraftStore = s); waitForStore("UserStore", s => UserStore = s); diff --git a/src/webpack/common/types/stores.d.ts b/src/webpack/common/types/stores.d.ts index 8e89a6e20..d6bf3aaf3 100644 --- a/src/webpack/common/types/stores.d.ts +++ b/src/webpack/common/types/stores.d.ts @@ -182,3 +182,10 @@ export class GuildStore extends FluxStore { getRoles(guildId: string): Record; getAllGuildRoles(): Record>; } + +export type useStateFromStores = ( + stores: t.FluxStore[], + mapper: () => T, + dependencies?: any, + isEqual?: (old: T, newer: T) => boolean +) => T;