Reactjs 带有React Redux的类型脚本,连接类型

Reactjs 带有React Redux的类型脚本,连接类型,reactjs,react-redux,typescript-typings,Reactjs,React Redux,Typescript Typings,我有一个连接到redux的HOC,如下所示: const withSignIn = (WrappedComponent: React.FC<WithSignInProps>) => { const mapStateToProps = ({ auth }: AuthRootState) => ({ error: auth.error, loading: auth.loading }); const mapDispatchToProps = {

我有一个连接到redux的HOC,如下所示:

const withSignIn = (WrappedComponent: React.FC<WithSignInProps>) => {
  const mapStateToProps = ({ auth }: AuthRootState) => ({
    error: auth.error,
    loading: auth.loading
  });

  const mapDispatchToProps = {
    signIn
  };

  return connect(mapStateToProps, mapDispatchToProps)(WrappedComponent);
};

export default withSignIn;
constwithsignin=(WrappedComponent:React.FC)=>{
常量MapStateTops=({auth}:AuthRootState)=>({
错误:auth.error,
加载:auth.loading
});
const mapDispatchToProps={
签名
};
返回连接(mapStateToProps、mapDispatchToProps)(WrappedComponent);
};
导出默认值;

我在函数
中缺少返回类型,但我不知道应该转换什么类型的函数,它在那里返回一个
connect()
函数,有什么提示吗?

我想你看到的就是这里

更准确地说,这条线

const connector = connect(mapState, mapDispatch)

// The inferred type will look like:
// {isOn: boolean, toggleOn: () => void}
type PropsFromRedux = ConnectedProps<typeof connector>
type Props = PropsFromRedux & {
  backgroundColor: string
}

const connector=connect(mapState,mapDispatch)
//推断的类型如下所示:
//{isOn:boolean,toggleOn:()=>void}
类型PropsFromRedux=ConnectedProps
类型Props=PropsFromRedux&{
背景颜色:字符串
}
我猜你回来的是

React.FC<WithSignInProps & PropsFromRedux>
React.FC
我没有足够的代码自己尝试,请告诉我它是否适合您:)