Я пытаюсь получить доступ к текущему состоянию магазина в результате, чтобы я мог сохранить свою текущую корзину локально. Я следовал за документами, но я продолжаю получать ошибку TS. Ниже мой аффект и ошибка его выбрасывание. Я не уверен, что является причиной проблемы здесь, поскольку я не знаком с ошибкой.
ОШИБКА в src / app / cart / store / cart.effects.ts (15,42) : ошибка TS2493: тип кортежа '[never, ProductInterface []]' длиной '2' не имеет элемента с индексом '2'. [ng] src / app / cart / store / cart.effects.ts (15,54): ошибка TS2493: тип кортежа '[never, ProductInterface []]' длины '2' не имеет элемента с индексом '3'.
import {Injectable} from '@angular/core';
import {Actions, createEffect, ofType} from '@ngrx/effects';
import {Store, select} from '@ngrx/store';
import {ProductInterface} from '../../interfaces/product.interface';
import {of} from 'rxjs'
import {CartActions, addToCart, clearCart, removeFromCart, updateCartQuantity, } from './cart.actions';
import {withLatestFrom, switchMap} from 'rxjs/operators';
import {Storage} from '@ionic/storage';
@Injectable()
export class CartEffects {
storeCart$ = createEffect(() => this.actions$.pipe(
ofType('[Cart Component] Add To Cart'),
withLatestFrom(this.store.pipe(select('cart'))),
switchMap(([action: CartActions, storeState: ProductInterface[]]) => {
this.storage.set('cart', storeState);
return of(action)
})))
constructor(
private actions$: Actions,
private storage: Storage,
private store: Store<{cart: ProductInterface[]}>
) {}
}