没有重载匹配此调用-简单saga示例中的redux-saga错误

时间:2020-06-15 11:53:57

标签: redux redux-saga

以下代码给出了错误:No overload matches this call

const deleteListItem = (id: string) =>
  axios.delete(`http://localhost:4000/api/delete/${id}`);

function* deleteSaga(action: DeleteItemAction) {
  try {
    yield call(deleteListItem, action.id);
    yield put({
      type: DELETE_SUCCESS,
    });
  } catch (error) {
    yield put({
      type: DELETE_ERROR,
    });
  }
}

完整错误:

最后一次重载给出了以下错误。 类型'(id:string)=> Promise>'的参数不能分配给类型'{ fn :(此: 不知道,... args:any [])=> any; }'。 类型'(id:字符串)=>承诺>'缺少类型'{的以下属性:context; unknown; fn :(此: 不知道,... args:any [])=> any; }':上下文,fn TS2769

我已经遍历了所有redux-saga问题,但没有一个帮助我...

我可以做(action: any),但这不是我的解决方案...我的行动界面:

interface DeleteItemAction {
  id?: string;
}

0 个答案:

没有答案