redux-saga 使用yield报ts类型错误解决方案:
*getPlanById(
{ payload: id }: any, { call, put, select }: any
) {
const res: any = yield call(planViewService.apiGetPlanById, id);
if (res.code === 0) {
message.info('加载数据成功');
} else {
message.error('加载数据失败');
}
},
},
上述代码会报
"yield" 表达式隐式导致 "any" 类型,因为它的包含生成器缺少返回类型批注。ts(7057)
错误
解决方法:
*getPlanById(
{ payload: id }: any, { call, put, select }: any
): any {
const res: any = yield call(planViewService.apiGetPlanById, id);
if (res.code === 0) {
message.info('加载数据成功');
} else {
message.error('加载数据失败');
}
},
},
给方法增加返回类型any
“yield“ 表达式隐式导致 “any“ 类型,因为它的包含生成器缺少返回类型批注。ts(7057)
最新推荐文章于 2024-03-22 08:55:58 发布