title: NGRX reducer problem : Argument of type "X" is not assignable to parameter of type "Y"
body: <p>I got an error after a successfull compilation of an angular app build with ngrx.</p>
  <pre><code>ERROR in src/app/store/cart-items.reducer.ts:17:62 - error TS2345: Argument of type '{ items: CartItem[]; bestCommercialOfferValue: number; }' is not assignable to parameter of type 'CartItemsState'.
    Property 'commercialOffers' is missing in type '{ items: CartItem[]; bestCommercialOfferValue: number; }' but required in type 'CartItemsState'.
  
  17     on(DeleteCartItem, (state, action) =&gt; (deleteReturnState(state, action.isbn))),
                                                                  ~~~~~
  
    src/app/store/cartItemsState.ts:7:5
      7     commercialOffers: CommercialOffer[];
            ~~~~~~~~~~~~~~~~
      'commercialOffers' is declared here.
  src/app/store/cart-items.reducer.ts:18:73 - error TS2345: Argument of type '{ items: CartItem[]; bestCommercialOfferValue: number; }' is not assignable to parameter of type 'CartItemsState'.
  
  18     on(UpdateQuantityToBuyCartItem, (state, action) =&gt; (GetUpdatedState(state, action.cartItem))),
                                                                             ~~~~~
  </code></pre>
  <p>This error appear in a specific reducer file cart-item.reducer.ts after adding a field commercialOffers on the concerned state object.</p>
  <pre><code>import { CartItem } from '../models/cartItem';
  import { CommercialOffer } from '../models/commercialOffer';
  
  export interface CartItemsState {
      items: CartItem[];
      bestCommercialOfferValue: number;
      commercialOffers: CommercialOffer[];
  }
  </code></pre>
  <p>The reducer file concerned looks like this :</p>
  <pre><code>import { Action, createReducer, on } from '@ngrx/store';
  import { CartItem } from '../models/cartItem';
  import { CommercialOffer } from '../models/commercialOffer';
  import { AddCartItem, DeleteCartItem, UpdateQuantityToBuyCartItem, ClearCart, ApiGetCommercialOffersSuccess } from './actions';
  import { CartItemsState } from './cartItemsState';
  
  
  export const initialState: CartItemsState = {
      items: [],
      bestCommercialOfferValue: 0,
      commercialOffers: []
  };
  
  const _cartItemsReducer = createReducer(
      initialState,
      on(AddCartItem, (state, action) =&gt; ({ items: [...state.items, action.data], bestCommercialOfferValue: state.bestCommercialOfferValue })),
      on(DeleteCartItem, (state, action) =&gt; (deleteReturnState(state, action.isbn))),
      on(UpdateQuantityToBuyCartItem, (state, action) =&gt; (GetUpdatedState(state, action.cartItem))),
      on(ClearCart, (state, action) =&gt; ({ items: [], bestCommercialOfferValue: 0, commercialOffers: [] })),
      on(ApiGetCommercialOffersSuccess, (state, action) =&gt; ({ items: state.items, bestCommercialOfferValue: getBestCommercialOffer(state.items, action.commercialOffers) })));
  
  function getBestCommercialOffer(actualCartItems: CartItem[], bunchOfCommercialOffers: CommercialOffer[]): number {
  
  const subTotal = actualCartItems.reduce((sum, current) =&gt; sum + current.bookInfos.price * current.quantityToBuy, 0);
  const reductionValues: number[] = [];
  
  bunchOfCommercialOffers.forEach(actualCommercialOffer =&gt; {
      if (actualCommercialOffer.type == &quot;percentage&quot;) {
          reductionValues.push(actualCommercialOffer.value);
      } else if (actualCommercialOffer.type == &quot;minus&quot;) {
          reductionValues.push(actualCommercialOffer.value);
      } else if (actualCommercialOffer.type == &quot;slice&quot;) {
          const sliceValue = actualCommercialOffer.sliceValue;
          const reductionValue = actualCommercialOffer.value;
          const multiply = Math.trunc(subTotal / sliceValue);
  
          reductionValues.push(reductionValue * multiply);
      }});
  
      return reductionValues.reduce((previousValue, actualValue) =&gt; previousValue = previousValue &gt; actualValue ? previousValue : actualValue, 0);}
  
  
  function deleteReturnState(actualCartItemsState: CartItemsState, isbn: string): CartItemsState {
      return {
          items: actualCartItemsState.items.filter(item =&gt; item.bookInfos.isbn != isbn),
          bestCommercialOfferValue: actualCartItemsState.bestCommercialOfferValue,
          commercialOffers: actualCartItemsState.commercialOffers
      }
  }
  
  function GetUpdatedState(actualCartItemsState: CartItemsState, cartItemToUpdate: CartItem): CartItemsState {
      const newList: CartItem[] = [];
  
      actualCartItemsState.items.forEach(cartItem =&gt; {
  
      const newCartItem = &lt;CartItem&gt;{
          bookInfos: cartItem.bookInfos,
          quantityToBuy: cartItem.quantityToBuy
      }
  
      if (cartItem.bookInfos.isbn == cartItemToUpdate.bookInfos.isbn) {
          newCartItem.quantityToBuy = cartItemToUpdate.quantityToBuy;
      }
  
      newList.push(newCartItem)})
  
      return {
          items: newList,
          bestCommercialOfferValue: actualCartItemsState.bestCommercialOfferValue,
          commercialOffers: actualCartItemsState.commercialOffers
      }}
  
  export function cartItemsReducer(state: CartItemsState | undefined, action: Action) {
      return _cartItemsReducer(state, action);
  }
  </code></pre>
  <p>What is strange is that my app can run perfectly even with this error.</p>