From a8ee6d18df439b455b6c57331ea418b51c52dfd1 Mon Sep 17 00:00:00 2001 From: James Phillips Date: Wed, 20 Oct 2021 21:45:59 -0700 Subject: [PATCH 1/2] Allow use of createForm() instance with
Signed-off-by: James Phillips --- typescript/ReactFinalForm.test.tsx | 18 +++++++++++++++++- typescript/index.d.ts | 19 ++++++++++++++----- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/typescript/ReactFinalForm.test.tsx b/typescript/ReactFinalForm.test.tsx index bbe7445..2d1db18 100644 --- a/typescript/ReactFinalForm.test.tsx +++ b/typescript/ReactFinalForm.test.tsx @@ -1,7 +1,7 @@ /* tslint:disable: no-shadowed-variable */ /* eslint-disable @typescript-eslint/no-unused-vars */ -import { Decorator, Mutator } from "final-form"; +import { Decorator, Mutator, createForm } from "final-form"; import * as React from "react"; import { Field, Form } from "react-final-form"; @@ -186,3 +186,19 @@ function withWrongTypedDecorator() { /> ); } + +// with form api instance +function withFormApiInstance() { + return ; +} + +// with form api instance +function withFormApiInstanceAndSubmit() { + return ( + + ); +} diff --git a/typescript/index.d.ts b/typescript/index.d.ts index 6709de6..5a2b2ef 100644 --- a/typescript/index.d.ts +++ b/typescript/index.d.ts @@ -79,18 +79,27 @@ export interface RenderableProps { render?: (props: T) => React.ReactNode; } -export interface FormProps< - FormValues = Record, - InitialFormValues = Partial, -> extends Config, +interface FormManualProps { + form: FormApi; +} + +interface FormAutoConfigureProps + extends Config, RenderableProps> { subscription?: FormSubscription; decorators?: Array>; - form?: FormApi; initialValuesEqual?: (a?: AnyObject, b?: AnyObject) => boolean; + form?: undefined; [otherProp: string]: any; } +export type FormProps< + FormValues = Record, + InitialFormValues = Partial, +> = + | FormManualProps + | FormAutoConfigureProps; + export interface UseFieldConfig { afterSubmit?: () => void; allowNull?: boolean; From 7db94037fe7d91465d6d1b0f03612c0252aaf35d Mon Sep 17 00:00:00 2001 From: James Phillips Date: Wed, 20 Oct 2021 22:07:05 -0700 Subject: [PATCH 2/2] update comment Signed-off-by: James Phillips --- typescript/ReactFinalForm.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/ReactFinalForm.test.tsx b/typescript/ReactFinalForm.test.tsx index 2d1db18..265764c 100644 --- a/typescript/ReactFinalForm.test.tsx +++ b/typescript/ReactFinalForm.test.tsx @@ -192,7 +192,7 @@ function withFormApiInstance() { return ; } -// with form api instance +// with form api instance & invalid prop function withFormApiInstanceAndSubmit() { return (