目前在redux-form中正确输入dispatch
函数时出现了问题。
onSubmit
函数接受两个参数:
const onSubmit = (values, dispatch) => {...};
但是,它与来自dispatch
的{{1}}不完全相同。
我的意思是,它失去了打字。无论如何我都可以输入它,打字稿不会丢失任何错误,例如redux
即使我的组件中的任何地方都没有..., dispatch: Dispatch<{ foo: 'bar' }>)
密钥。
foo
类型来自Dispatch
,如果redux
与dispatch
一起使用,则效果正常,例如在connect
函数中。
问:如何正确输入redux-form中的mapDispatchToProps
函数?
进入dispatch
初始化位置时,在Dispatch
节点包中的index.d.ts
文件中,有以下界面:
redux
为什么省略export interface Dispatch<S> {
<A extends Action>(action: A): A;
}
?这就是为什么如果我把任何东西作为S
的参数,typescript会接受它吗?
谢谢!