我用以下代码输入了这个问题:
“类型‘(response: IResponse) => void’的参数不可分配给类型‘(value: void) => void | PromiseLike’的参数”。
并用 check() 函数来解决这个问题。
请你帮助我好吗?我真的不知道如何解决。谢谢!
interface IResponse {
isChecked: boolean;
}
type TResponse = IResponse;
.....
function dispatchAsync<TResponsePayload>(dispatch: Dispatch, actionType: string, asyncCall: () => Promise<TResponsePayload>): any;
....
check = async () => {
const {actions, param} = this.props;
await actions.getInfoById(param.id).then(
(response: IResponse) => {
this.setState({isChecked: response.isChecked});
}
);
};
.....
getInfoById = async (id: string): Promise<void> =>
dispatchAsync<TPermission>(this.dispatch, CHECK_ACTION, async () => {
return await this.service.getInfoById(id);
});Run Code Online (Sandbox Code Playgroud)