Revert "feat(redux-form): infer field name and type in InjectedFormProps (#35918)" (#36163)

This reverts commit 4f67985026.
This commit is contained in:
Andrew Luca
2019-06-15 23:27:32 -07:00
committed by Ron Buckton
parent 7fa8360d82
commit 133fab18f2
3 changed files with 11 additions and 50 deletions
+3 -4
View File
@@ -16,13 +16,12 @@
// Ethan Setnik <https://github.com/esetnik>
// Walter Barbagallo <https://github.com/bwlt>
// Kota Marusue <https://github.com/mrsekut>
// Andrew Luca <https://github.com/iamandrewluca>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import {
ComponentClass,
StatelessComponent,
ReactElement
ComponentClass,
StatelessComponent,
ReactElement
} from "react";
export type FieldType = "Field" | "FieldArray";
+8 -8
View File
@@ -68,15 +68,15 @@ export interface RegisteredField {
type: "Field" | "FieldArray";
}
export interface InjectedFormProps<FormData = any, P = {}, ErrorType = string> {
export interface InjectedFormProps<FormData = {}, P = {}, ErrorType = string> {
anyTouched: boolean;
array: InjectedArrayProps;
asyncValidate(): void;
asyncValidating: keyof FormData | boolean;
autofill<F extends keyof FormData>(field: F, value: FormData[F]): void;
blur<F extends keyof FormData>(field: F, value: FormData[F]): void;
change<F extends keyof FormData>(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<FormData = any, P = {}, ErrorType = string> {
submitFailed: boolean;
submitSucceeded: boolean;
submitting: boolean;
touch(...field: Array<keyof FormData>): void;
untouch(...field: Array<keyof FormData>): void;
touch(...field: string[]): void;
untouch(...field: string[]): void;
valid: boolean;
warning: any;
registeredFields: { [name: string]: RegisteredField };
-38
View File
@@ -477,41 +477,3 @@ class TestFormComponent2 extends React.Component<TestFormComponentProps & Inject
return null;
}
}
function TestInjectedFormPropsWithType(props: InjectedFormProps<{ foo: string; }>) {
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;
}