在 Typescript 中使用 Redux-Form 我想使用 WrappedFieldProps<S> 接口,但它没有被导出。我做错了吗?

Using Redux-Form in Typescript I would like to use the WrappedFieldProps<S> interface but it isn't exported. Am I doing it wrong?

我正在使用 Redux-Form 并使用使用函数呈现的 <Field> 组件(如 Redux-Form 网站上的同步验证示例:http://redux-form.com/6.0.0-rc.1/examples/syncValidation/)。

因为我使用的是 Typescript,所以我想给 renderField 函数的参数一个类型。参数的类型似乎基于接口 WrappedFieldProps<S> 但是该接口未导出,因此我无法使用它。

所以我想使用 WrappedFieldProps< S> 是对的,还是有更好的方法?

示例代码:

interface RenderFieldProps extends WrappedFieldProps<AppState> {
    placeholder: string,
    type: string,
};

public render(): JSX.Element {
    return (
        <form onSubmit={this.props.handleSubmit(this.handleFormSubmit)}>
            <Field name="email" component={this.renderField} type="text" placeholder="Add your email address"/>
            <button type="submit">Submit form</button>
        </form>
    );
}

private renderField = (props: RenderFieldProps) => (
    <div>
        <input {...props.input} placeholder={props.placeholder} type={props.type}/>
    </div>
);

我不确定你从哪里得到你的类型定义,但是如果你检查 this repository 中的 index.d.ts,你会看到 WrappedFieldProps 被导出到这一行:

export * from "./lib/Field";

所以,基本上您可以使用以下方式导入它:

import {WrappedFieldProps } from "redux-form";