type TResultCategory<T> = {
title: string;
items: T[];
description?: string;
delete(dispatch: Dispatch<{}>): void;
update?(dispatch: Dispatch<{}>, products: TCartProduct[]): void;
}
type TResult = (TResultCategory<TResultProductQueue> | TResultCategory<TCartProduct>)[]
// ...
const [
unavailableCategoriesQueue,
updateUnavailableCategoriesQueue
] = useState<TResult>([]),
const onContinue = (): void => {
unavailableCategoriesQueue[0].delete(dispatch); // <= error
unavailableCategoriesQueue.slice(1).forEach((category) => {
category?.update(dispatch, unavailableCategoriesQueue[0]?.items); // <= error
});
};
//...
The UnavailableCategoriesQueue is a collection containing different types of categories, each with a mandatory delete method.