【发布时间】:2018-06-28 16:12:20
【问题描述】:
我正在使用 NGRX 实体适配器来初始化状态(问题仅出现在 getInitialState 中)。
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
});
}
// ...
当我想在状态对象上使用扩展运算符时,我得到一个错误:
ERROR in src/app/events/reducers/events.reducer.ts(36,35): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
这是我的 tsconfig.json 文件
{
"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
}
【问题讨论】:
标签: angular typescript ngrx