0
import { StoreModule } from "@ngrx/store";
import { currentPurchase } from "../shared/index";

@NgModule({
 imports: [
        IonicModule.forRoot(MyApp, {}),
        HttpModule,
        StoreModule.provideStore({currentPurchase})
    ]
..

I am getting Property currentPurchase' does not exist on type typeof app.module. The imported reducer looks like this:

import { ActionReducer, Action } from "@ngrx/store";
import { ActionType } from "./action-type";
import { PurchaseModel } from "../purchase/purchase.model";

export const currentPurchase: ActionReducer<PurchaseModel> = (state:PurchaseModel = new PurchaseModel(), action:Action) => {

    switch (action.type) {

        case ActionType.SET_PURCHASE:
            return (action.payload !== null) ? action.payload : new PurchaseModel();
        case ActionType.UPDATE_PURCHASE:
            return Object.assign({}, state, action.payload);
        default:
            return state;
    }
};

Also:

enter image description here

Any help is appreciated.

Stephan Kristyn
  • 15,015
  • 14
  • 88
  • 147

2 Answers2

1

For your second error, you need to install the es6-shim types as described here: https://github.com/angular/angular/issues/7033#issuecomment-183249303

You can do this with types in your package json as well by:

npm i @types/es6-shim -S
KwintenP
  • 4,637
  • 2
  • 22
  • 30
1

Use an untyped function instead of typed const in the reducers, e.g. like:

Failing with ng2-final AoT:

export const settings: ActionReducer<SettingsModel> = (state:SettingsModel = new SettingsModel(), action:Action) => {

    switch (action.type) {
        case ActionType.SET_SETTINGS:
            return (action.payload !== null) ? action.payload : new SettingsModel();
        case ActionType.UPDATE_SETTINGS:
            console.log(Object.assign(state, {pin: Object.assign(state.pin, action.payload.pin)}));
            return Object.assign({}, state, {pin: Object.assign(state.pin, action.payload.pin)});
        default:
            return state;
    }
};

Working with ng2-final AoT:

export function settings (state:SettingsModel = new SettingsModel(), action:Action) {

    switch (action.type) {
        case ActionType.SET_SETTINGS:
            return (action.payload !== null) ? action.payload : new SettingsModel();
        case ActionType.UPDATE_SETTINGS:
            console.log(Object.assign(state, {pin: Object.assign(state.pin, action.payload.pin)}));
            return Object.assign({}, state, {pin: Object.assign(state.pin, action.payload.pin)});
        default:
            return state;
    }
};

Read more about this (it wont say why): https://github.com/ngrx/store/issues/190

Stephan Kristyn
  • 15,015
  • 14
  • 88
  • 147