升级ngrx 2 - > 4.输入解构数组

时间:2018-03-08 20:47:44

标签: angular typescript ngrx ngrx-effects ngrx-store-4.0

错误在于action中的.map参数后面会出现逗号。

将鼠标悬停在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",

1 个答案:

答案 0 :(得分:1)

withLastFrom()实际上返回一个元组类型,并声明元组中每个元素的类型,我们需要做类似的事情

map(([action, store]: [DataActions.AddDataAction, AppState])=>