我正在从这里阅读有关对象传播语法的信息,并尝试在我的项目中使用它,我的设置如下:
- 角度 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'
有任何想法吗?谢谢!