From 1e2dbd77783f1d86335c1bd2f81b404e7b77a936 Mon Sep 17 00:00:00 2001 From: Chaim Lev-Ari Date: Sat, 19 Aug 2023 20:31:00 +0300 Subject: [PATCH] refactor(ui/tables): remove temp type --- app/react/components/datatables/types.ts | 15 --------------- app/react/components/datatables/useTableState.ts | 7 +++++-- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/app/react/components/datatables/types.ts b/app/react/components/datatables/types.ts index b81aaeec5..c9952641c 100644 --- a/app/react/components/datatables/types.ts +++ b/app/react/components/datatables/types.ts @@ -100,18 +100,3 @@ export function createPersistedStore( ) ); } - -/** this class is just a dummy class to get return type of createPersistedStore - * can be fixed after upgrade to ts 4.7+ - * https://stackoverflow.com/a/64919133 - */ -class Wrapper { - // eslint-disable-next-line class-methods-use-this - wrapped() { - return createPersistedStore('', ''); - } -} - -export type CreatePersistedStoreReturn< - T extends BasicTableSettings = BasicTableSettings -> = ReturnType['wrapped']>; diff --git a/app/react/components/datatables/useTableState.ts b/app/react/components/datatables/useTableState.ts index 5681a5d43..20d8cceb3 100644 --- a/app/react/components/datatables/useTableState.ts +++ b/app/react/components/datatables/useTableState.ts @@ -2,7 +2,7 @@ import { useMemo, useState } from 'react'; import { useStore } from 'zustand'; import { useSearchBarState } from './SearchBar'; -import { BasicTableSettings, CreatePersistedStoreReturn } from './types'; +import { BasicTableSettings, createPersistedStore } from './types'; export type TableState = TSettings & { setSearch: (search: string) => void; @@ -11,7 +11,10 @@ export type TableState = TSettings & { export function useTableState< TSettings extends BasicTableSettings = BasicTableSettings ->(store: CreatePersistedStoreReturn, storageKey: string) { +>( + store: ReturnType>, + storageKey: string +) { const settings = useStore(store); const [search, setSearch] = useSearchBarState(storageKey);