From f8ffc07b18c1c2f1ec6a070489e278bc211d8125 Mon Sep 17 00:00:00 2001 From: Maddi Joyce Date: Tue, 12 Jun 2018 17:06:39 +1000 Subject: [PATCH 1/4] Adding 'undocumented' parameter to selectors. --- types/redux-form/index.d.ts | 20 ++++++++++++-------- types/redux-form/lib/reduxForm.d.ts | 3 ++- types/redux-form/lib/selectors.d.ts | 8 ++++---- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/types/redux-form/index.d.ts b/types/redux-form/index.d.ts index 8ee5fa9698..668c1228d4 100644 --- a/types/redux-form/index.d.ts +++ b/types/redux-form/index.d.ts @@ -7,14 +7,11 @@ // Alex Young // Anton Novik // Huw Martin +// Maddi Joyce // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 -import { - ComponentClass, - StatelessComponent, - ReactElement -} from "react"; +import { ComponentClass, StatelessComponent, ReactElement } from "react"; export type FieldType = "Field" | "FieldArray"; @@ -23,7 +20,7 @@ export interface ErrorOther { } export type FormErrors = { - [P in keyof FormData]?: ReactElement | string | ErrorOther; + [P in keyof FormData]?: ReactElement | string | ErrorOther }; export interface WarningOther { @@ -31,7 +28,7 @@ export interface WarningOther { } export type FormWarnings = { - [P in keyof FormData]?: ReactElement | string | WarningOther; + [P in keyof FormData]?: ReactElement | string | WarningOther }; export interface RegisteredFieldState { @@ -39,7 +36,14 @@ export interface RegisteredFieldState { type: FieldType; } -export type Omit = Pick; +export type Omit = Pick< + T, + ({ [P in keyof T]: P } & + { [P in K]: never } & { + [x: string]: never; + [x: number]: never; + })[keyof T] +>; export * from "./lib/reduxForm"; export * from "./lib/Field"; diff --git a/types/redux-form/lib/reduxForm.d.ts b/types/redux-form/lib/reduxForm.d.ts index 128845f08f..07f8e197ca 100644 --- a/types/redux-form/lib/reduxForm.d.ts +++ b/types/redux-form/lib/reduxForm.d.ts @@ -20,6 +20,7 @@ import { export type FormSubmitHandler = (values: FormData, dispatch: Dispatch, props: P) => void | FormErrors | Promise; +export type GetFormState = (state: any) => FormStateMap; export interface SubmitHandler { ( submit: FormSubmitHandler, @@ -105,7 +106,7 @@ export interface ConfigProps { destroyOnUnmount?: boolean; enableReinitialize?: boolean; forceUnregisterOnUnmount?: boolean; - getFormState?(state: any): FormStateMap; + getFormState?: GetFormState; immutableProps?: string[]; initialValues?: Partial; keepDirtyOnReinitialize?: boolean; diff --git a/types/redux-form/lib/selectors.d.ts b/types/redux-form/lib/selectors.d.ts index 4d224b5b82..a4bce56b36 100644 --- a/types/redux-form/lib/selectors.d.ts +++ b/types/redux-form/lib/selectors.d.ts @@ -1,8 +1,8 @@ -import { FormErrors } from "../index"; +import { FormErrors, GetFormState } from "../index"; -export type DataSelector = (formName: string) => (state: State) => FormData; -export type ErrorSelector = (formName: string) => (state: State) => FormErrors; -export type BooleanSelector = (formName: string) => (state: State) => boolean; +export type DataSelector = (formName: string, getFormState?: GetFormState) => (state: State) => FormData; +export type ErrorSelector = (formName: string, getFormState?: GetFormState) => (state: State) => FormErrors; +export type BooleanSelector = (formName: string, getFormState?: GetFormState) => (state: State) => boolean; export const getFormValues: DataSelector; export const getFormInitialValues: DataSelector; From 11b289bbc1a1259c338f1db4e959f697b8cd4088 Mon Sep 17 00:00:00 2001 From: Maddi Joyce Date: Tue, 12 Jun 2018 17:12:53 +1000 Subject: [PATCH 2/4] Revert formatting changes. --- types/redux-form/index.d.ts | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/types/redux-form/index.d.ts b/types/redux-form/index.d.ts index 668c1228d4..1a3a4f1952 100644 --- a/types/redux-form/index.d.ts +++ b/types/redux-form/index.d.ts @@ -10,8 +10,11 @@ // Maddi Joyce // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 - -import { ComponentClass, StatelessComponent, ReactElement } from "react"; +import { + ComponentClass, + StatelessComponent, + ReactElement +} from "react"; export type FieldType = "Field" | "FieldArray"; @@ -20,7 +23,7 @@ export interface ErrorOther { } export type FormErrors = { - [P in keyof FormData]?: ReactElement | string | ErrorOther + [P in keyof FormData]?: ReactElement | string | ErrorOther; }; export interface WarningOther { @@ -28,7 +31,7 @@ export interface WarningOther { } export type FormWarnings = { - [P in keyof FormData]?: ReactElement | string | WarningOther + [P in keyof FormData]?: ReactElement | string | WarningOther; }; export interface RegisteredFieldState { @@ -36,14 +39,7 @@ export interface RegisteredFieldState { type: FieldType; } -export type Omit = Pick< - T, - ({ [P in keyof T]: P } & - { [P in K]: never } & { - [x: string]: never; - [x: number]: never; - })[keyof T] ->; +export type Omit = Pick; export * from "./lib/reduxForm"; export * from "./lib/Field"; From a8f6f1345e1631c6e19fa05b4cc2ec7d83ee4a88 Mon Sep 17 00:00:00 2001 From: Maddi Joyce Date: Tue, 12 Jun 2018 17:18:29 +1000 Subject: [PATCH 3/4] Bumping version number, fixing formNames selector. --- types/redux-form/index.d.ts | 2 +- types/redux-form/lib/selectors.d.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/redux-form/index.d.ts b/types/redux-form/index.d.ts index 1a3a4f1952..3488114a9b 100644 --- a/types/redux-form/index.d.ts +++ b/types/redux-form/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for redux-form 7.2 +// Type definitions for redux-form 7.3 // Project: https://github.com/erikras/redux-form // Definitions by: Carson Full // Daniel Lytkin diff --git a/types/redux-form/lib/selectors.d.ts b/types/redux-form/lib/selectors.d.ts index a4bce56b36..936319181d 100644 --- a/types/redux-form/lib/selectors.d.ts +++ b/types/redux-form/lib/selectors.d.ts @@ -3,6 +3,7 @@ import { FormErrors, GetFormState } from "../index"; export type DataSelector = (formName: string, getFormState?: GetFormState) => (state: State) => FormData; export type ErrorSelector = (formName: string, getFormState?: GetFormState) => (state: State) => FormErrors; export type BooleanSelector = (formName: string, getFormState?: GetFormState) => (state: State) => boolean; +export type NamesSelector = (getFormState?: getFormValues) => (state: State) => string[]; export const getFormValues: DataSelector; export const getFormInitialValues: DataSelector; @@ -12,7 +13,7 @@ export const getFormAsyncErrors: ErrorSelector; export const getFormSyncWarnings: ErrorSelector; export const getFormSubmitErrors: ErrorSelector; export const getFormError: ErrorSelector; -export function getFormNames(state: any): string[]; +export const getFormNames: NamesSelector; export const isDirty: BooleanSelector; export const isPristine: BooleanSelector; export const isValid: BooleanSelector; From 594ec50c1b087f0d9f7d6cfc91fd4f41f8f7b4d1 Mon Sep 17 00:00:00 2001 From: Maddi Joyce Date: Wed, 13 Jun 2018 09:25:45 +1000 Subject: [PATCH 4/4] Typo in selectors --- types/redux-form/lib/selectors.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/redux-form/lib/selectors.d.ts b/types/redux-form/lib/selectors.d.ts index 936319181d..eea4444275 100644 --- a/types/redux-form/lib/selectors.d.ts +++ b/types/redux-form/lib/selectors.d.ts @@ -3,7 +3,7 @@ import { FormErrors, GetFormState } from "../index"; export type DataSelector = (formName: string, getFormState?: GetFormState) => (state: State) => FormData; export type ErrorSelector = (formName: string, getFormState?: GetFormState) => (state: State) => FormErrors; export type BooleanSelector = (formName: string, getFormState?: GetFormState) => (state: State) => boolean; -export type NamesSelector = (getFormState?: getFormValues) => (state: State) => string[]; +export type NamesSelector = (getFormState?: GetFormState) => (state: State) => string[]; export const getFormValues: DataSelector; export const getFormInitialValues: DataSelector;