Typing redux forms v7 with TypeScript and React

后端 未结 5 2067
野性不改
野性不改 2020-12-29 15:29

I\'ve got a plain react-redux-powered form. I wish for there to be a form.container.tsx and a form.component.tsx, where form.container.tsx holds all the connections to redux

5条回答
  •  暖寄归人
    2020-12-29 15:44

    What we ended up doing was to close our eyes and override the default types with a type declaration file:

    redux-forms.d.ts:

    declare module 'redux-form' {
      type anyProps = { [key: string]: {} }
      function Field(): React.Component;
      function reduxForm({}): (c: T) => T
      function reducer(): object
      interface SubmissionError {
        new(error?: {}) : Error;
      }
      function getFormValues(formName: string): (formName: {}) => {}
      function stopSubmit(formName: string, errorObject?: {}): any
      function isSubmitting(formName: string): any
      function setSubmitFailed(formName: string): any
      function setSubmitSucceeded(formName: string): any
      function touch(formName: string): any
      function clearSubmitErrors(formName: string): any
      function getFormMeta(formName: string, ...fields: string[]): (state: {}) => {}
      function getFormSyncErrors(formName: string): (state: {}) => {}
      function getFormSubmitErrors(formName: string): (state: {}) => {}
      function getFormNames(): any
    }
    

提交回复
热议问题