【发布时间】:2017-08-30 16:49:10
【问题描述】:
我从here 阅读了有关对象传播语法的信息,我正在尝试在我的项目中使用它,我的设置如下:
- 角2
- 角度/cli 1.0.0-rc.0
- ngrx/核心 1.2.0
- ngrx/存储 2.2.1
- rxjs 5.1.0
- 打字稿 2.0.10
在我的 reducer.ts 中有
export interface State {
[id: number]: string
}
export function reducer(state= {}, action: Action): State {
case 'TEST':
return {
...state,
2: 'foo'
}
}
但是我得到了以下编译错误,我正在尝试找出问题所在:
Property assignment expected
Type '{ 2: string; state: State; }' is not assignable to type 'State'
Object literal may only specify known properties, and 'state' does not exist in type 'State'
有什么想法吗?谢谢!
【问题讨论】:
标签: javascript object redux ngrx spread-syntax