Utilizing NGRX Entity adapter for state initialization has been encountering an issue, specifically with the getInitialState
method.
export const initialState = adapter.getInitialState({
eventsError: null,
eventsLoading: false
});
export function reducer(
state = initialState,
action: EventsActions
): State {
switch (action.type) {
case EventsActionTypes.getAllEvents: {
return Object.assign({}, ...state, { // error line
eventsLoading: true
});
}
// ...
An error is triggered when attempting to use the spread operator on the state object:
ERROR in src/app/events/reducers/events.reducer.ts(36,35): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
The configuration in my tsconfig.json file is as follows:
{
"compilerOptions": {
"noImplicitAny": true,
"removeComments": true,
"sourceMap": true,
"target": "es6",
"module": "commonjs",
"experimentalDecorators": true,
"noEmitHelpers": false,
"emitDecoratorMetadata": true,
"declaration": false,
"lib": [
"es2015",
"dom"
],
"moduleResolution": "node",
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"noUnusedParameters": true
},
"compileOnSave": false,
"buildOnSave": false
}