Не уверен, какое сообщение об ошибке вы получаете, это может быть 2 вещи. Сначала вы можете указать, что [ShoppingList]
приведен как тип. также необходимо указать все параметры состояния
class TotalPrice extends React.Component<{}, TPState> {
public state = {
shoppingLists2: [ShoppingList] as ShoppingList[], // as ShoppingList[] may not be needed but dont know without the error message
sum: 0,
shoplistsums: [] // you were missing this item in your state, proabably what the issue was
}
}
РЕДАКТИРОВАТЬ: вам нужно определить тип для списка покупок .. вместо того, чтобы использовать его в качестве типа.
interface IShoppingList {
someKey: number
someOtherKey: string
}
тогда тип вашего штата
interface TPState {
shoppingLists2: IShoppingList[];
shoplistsums: number[];
sum: number;
}