[redux-form] typing for version 7.2

Add clearFields action;
update Validator type to accept optional name argument;
update FieldArray meta props to type `any`;
add shouldError and shouldWarn config props to reduxForm;
add getFormError selector
This commit is contained in:
Huw Martin
2018-02-22 13:31:12 +00:00
parent 425ca63a9e
commit d44c90df2d
7 changed files with 11 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
// Type definitions for redux-form 7.0
// Type definitions for redux-form 7.2
// Project: https://github.com/erikras/redux-form
// Definitions by: Carson Full <https://github.com/carsonf>
// Daniel Lytkin <https://github.com/aikoven>
@@ -6,6 +6,7 @@
// Luka Zakrajsek <https://github.com/bancek>
// Alex Young <https://github.com/alsiola>
// Anton Novik <https://github.com/tehbi4>
// Huw Martin <https://github.com/huwmartin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6

View File

@@ -14,7 +14,7 @@ import { Dispatch } from "redux";
export type Normalizer = (value: any, previousValue?: any, allValues?: any, previousAllValues?: any) => any;
export type Formatter = (value: any, name: string) => any;
export type Parser = (value: any, name: string) => any;
export type Validator = (value: any, allValues?: any, props?: any) => any;
export type Validator = (value: any, allValues?: any, props?: any, name?: any) => any;
export type EventHandler<Event> = (event: Event) => void;
export type EventWithDataHandler<Event> = (event?: Event, newValue?: any, previousValue?: any) => void;

View File

@@ -47,11 +47,11 @@ interface FieldsProps<FieldValue> {
interface FieldArrayMetaProps {
dirty: boolean;
error?: string;
error?: any;
form: string;
invalid: boolean;
pristine: boolean;
submitting: boolean;
valid: boolean;
warning?: string;
warning?: any;
}

View File

@@ -15,6 +15,7 @@ export interface ActionTypes {
CLEAR_SUBMIT: string;
CLEAR_SUBMIT_ERRORS: string;
CLEAR_ASYNC_ERROR: string;
CLEAR_FIELDS: string;
DESTROY: string;
FOCUS: string;
INITIALIZE: string;

View File

@@ -41,6 +41,7 @@ export declare function submit(form: string): FormAction;
export declare function clearSubmit(form: string): FormAction;
export declare function clearSubmitErrors(form: string): FormAction;
export declare function clearAsyncError(form: string, field: string): FormAction;
export declare function clearFields(form: string, keepTouched: boolean, persistentSubmitErrors: boolean, ...fields: string[]): FormAction;
export declare function touch(form: string, ...fields: string[]): FormAction;
export declare function unregisterField(form: string, name: string): FormAction;
export declare function untouch(form: string, ...fields: string[]): FormAction;
@@ -64,6 +65,7 @@ declare const actions: {
clearSubmit: typeof clearSubmit,
clearSubmitErrors: typeof clearSubmitErrors,
clearAsyncError: typeof clearAsyncError,
clearFields: typeof clearFields,
destroy: typeof destroy,
focus: typeof focus,
initialize: typeof initialize,

View File

@@ -116,6 +116,8 @@ export interface ConfigProps<FormData = {}, P = {}> {
propNamespace?: string;
pure?: boolean;
shouldValidate?(params: ValidateCallback<FormData, P>): boolean;
shouldError?(params: ValidateCallback<FormData, P>): boolean;
shouldWarn?(params: ValidateCallback<FormData, P>): boolean;
shouldAsyncValidate?(params: AsyncValidateCallback<FormData>): boolean;
touchOnBlur?: boolean;
touchOnChange?: boolean;

View File

@@ -11,6 +11,7 @@ export const getFormMeta: DataSelector;
export const getFormAsyncErrors: ErrorSelector;
export const getFormSyncWarnings: ErrorSelector;
export const getFormSubmitErrors: ErrorSelector;
export const getFormError: ErrorSelector;
export function getFormNames(state: any): string[];
export const isDirty: BooleanSelector;
export const isPristine: BooleanSelector;