升级 ngrx 2 -> 4。输入解构数组有问题
Upgrading ngrx 2 -> 4. Having issue with typing in de-structuring array
错误是在 .map
.
中的 action
参数后需要一个逗号
将鼠标悬停在 DataActions.AddDataAction
上时也会出现错误,显示 Tuple type '[Action, AppStore]' with length '2' cannot be assigned to tuple with length '5'
@Effect() addData$ = this.actions$
.ofType(DataActions.ADD_DATA)
.withLatestFrom(this.store$)
.map(([action: DataActions.AddDataAction, store: AppState]) => [action.payload, reducer.dataResults(store)])
.etc...
这是我的 package.json
中的相关软件包及其版本
"@ngrx/effects": "^4.1.1",
"@ngrx/router-store": "^4.1.1",
"@ngrx/store": "^4.1.1",
"@ngrx/store-devtools": "^4.1.1",
"typescript": "~2.4.0",
withLastFrom() 实际上 returns 一个元组类型并声明元组中每个元素的类型,我们需要做类似
的事情
map(([action, store]: [DataActions.AddDataAction, AppState])=>
错误是在 .map
.
action
参数后需要一个逗号
将鼠标悬停在 DataActions.AddDataAction
上时也会出现错误,显示 Tuple type '[Action, AppStore]' with length '2' cannot be assigned to tuple with length '5'
@Effect() addData$ = this.actions$
.ofType(DataActions.ADD_DATA)
.withLatestFrom(this.store$)
.map(([action: DataActions.AddDataAction, store: AppState]) => [action.payload, reducer.dataResults(store)])
.etc...
这是我的 package.json
"@ngrx/effects": "^4.1.1",
"@ngrx/router-store": "^4.1.1",
"@ngrx/store": "^4.1.1",
"@ngrx/store-devtools": "^4.1.1",
"typescript": "~2.4.0",
withLastFrom() 实际上 returns 一个元组类型并声明元组中每个元素的类型,我们需要做类似
的事情map(([action, store]: [DataActions.AddDataAction, AppState])=>