From 133fab18f2d2b8d201cd17e346d60382fe239e1c Mon Sep 17 00:00:00 2001 From: Andrew Luca Date: Sun, 16 Jun 2019 09:27:33 +0300 Subject: [PATCH] Revert "feat(redux-form): infer field name and type in InjectedFormProps (#35918)" (#36163) This reverts commit 4f6798502692ef33a1ae3d7c7f09ea9b523bdb0a. --- types/redux-form/index.d.ts | 7 +++-- types/redux-form/lib/reduxForm.d.ts | 16 +++++------ types/redux-form/redux-form-tests.tsx | 38 --------------------------- 3 files changed, 11 insertions(+), 50 deletions(-) diff --git a/types/redux-form/index.d.ts b/types/redux-form/index.d.ts index 58d0002053..34dd3d6cf0 100644 --- a/types/redux-form/index.d.ts +++ b/types/redux-form/index.d.ts @@ -16,13 +16,12 @@ // Ethan Setnik // Walter Barbagallo // Kota Marusue -// Andrew Luca // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.0 import { - ComponentClass, - StatelessComponent, - ReactElement + ComponentClass, + StatelessComponent, + ReactElement } from "react"; export type FieldType = "Field" | "FieldArray"; diff --git a/types/redux-form/lib/reduxForm.d.ts b/types/redux-form/lib/reduxForm.d.ts index b40e50e83a..e37214f5d0 100644 --- a/types/redux-form/lib/reduxForm.d.ts +++ b/types/redux-form/lib/reduxForm.d.ts @@ -68,15 +68,15 @@ export interface RegisteredField { type: "Field" | "FieldArray"; } -export interface InjectedFormProps { +export interface InjectedFormProps { anyTouched: boolean; array: InjectedArrayProps; asyncValidate(): void; - asyncValidating: keyof FormData | boolean; - autofill(field: F, value: FormData[F]): void; - blur(field: F, value: FormData[F]): void; - change(field: F, value: FormData[F]): void; - clearAsyncError(field: keyof FormData): void; + asyncValidating: string | boolean; + autofill(field: string, value: any): void; + blur(field: string, value: any): void; + change(field: string, value: any): void; + clearAsyncError(field: string): void; destroy(): void; dirty: boolean; error: ErrorType; @@ -91,8 +91,8 @@ export interface InjectedFormProps { submitFailed: boolean; submitSucceeded: boolean; submitting: boolean; - touch(...field: Array): void; - untouch(...field: Array): void; + touch(...field: string[]): void; + untouch(...field: string[]): void; valid: boolean; warning: any; registeredFields: { [name: string]: RegisteredField }; diff --git a/types/redux-form/redux-form-tests.tsx b/types/redux-form/redux-form-tests.tsx index 91087e4a22..5cd4ed3ce2 100644 --- a/types/redux-form/redux-form-tests.tsx +++ b/types/redux-form/redux-form-tests.tsx @@ -477,41 +477,3 @@ class TestFormComponent2 extends React.Component) { - props.asyncValidating === 'foo'; - props.asyncValidating === true; - props.asyncValidating === false; - props.autofill('foo', ''); - props.blur('foo', ''); - props.change('foo', ''); - props.clearAsyncError('foo'); - props.touch('foo'); - props.untouch('foo'); - props.asyncValidating === 'baz'; // $ExpectError - props.autofill('foo', 1); // $ExpectError - props.blur('foo', 1); // $ExpectError - props.change('foo', 1); // $ExpectError - props.autofill('baz', ''); // $ExpectError - props.blur('baz', ''); // $ExpectError - props.change('baz', ''); // $ExpectError - props.clearAsyncError('baz'); // $ExpectError - props.touch('baz'); // $ExpectError - props.untouch('baz'); // $ExpectError - - return null; -} - -function TestInjectedFormPropsWithoutType(props: InjectedFormProps) { - props.asyncValidating === 'foo'; - props.asyncValidating === true; - props.asyncValidating === false; - props.autofill('foo', ''); - props.blur('foo', ''); - props.change('foo', ''); - props.clearAsyncError('foo'); - props.touch('foo'); - props.untouch('foo'); - - return null; -}