pmi*_*nda 4 typescript reactjs typescript-typings
我有一个React这样的动作:
export const sigIn = () =>
async (dispatch: any) => {
dispatch({
type: SIGN_IN_REQUEST
});
};
Run Code Online (Sandbox Code Playgroud)
我得到一个:
ESLint: Argument 'dispatch' should be typed with a non-any type.(@typescript-eslint/explicit-module-boundary-types)
Run Code Online (Sandbox Code Playgroud)
作为对 的警告async。为什么?
编辑:对于这两个答案,我输入了类型Dispatch,redux但仍然有警告:
您收到错误是因为您使用了any,并且您的 lint 规则禁止这样做。解决方法是使用正确的调度类型,可以从 redux 导入:
import { Dispatch } from 'redux';
export const sigIn = () =>
async (dispatch: Dispatch) => {
dispatch({
type: SIGN_IN_REQUEST
})
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1819 次 |
| 最近记录: |