Redux-form的发送和打字稿

时间:2018-03-20 17:36:13

标签: javascript reactjs typescript redux react-redux

目前在redux-form中正确输入dispatch函数时出现了问题。

redux-form中的

onSubmit函数接受两个参数:

const onSubmit = (values, dispatch) => {...};

但是,它与来自dispatch的{​​{1}}不完全相同。

我的意思是,它失去了打字。无论如何我都可以输入它,打字稿不会丢失任何错误,例如redux即使我的组件中的任何地方都没有..., dispatch: Dispatch<{ foo: 'bar' }>)密钥。

foo类型来自Dispatch,如果reduxdispatch一起使用,则效果正常,例如在connect函数中。

:如何正确输入redux-form中的mapDispatchToProps函数?

重要:

进入dispatch初始化位置时,在Dispatch节点包中的index.d.ts文件中,有以下界面:

redux

为什么省略export interface Dispatch<S> { <A extends Action>(action: A): A; } ?这就是为什么如果我把任何东西作为S的参数,typescript会接受它吗?

谢谢!

0 个答案:

没有答案