diff --git a/typescript/ReactFinalForm.test.tsx b/typescript/ReactFinalForm.test.tsx index bbe7445..265764c 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 & invalid prop +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;