@@ -6,14 +6,15 @@ import type {
66 Decorator,
77 FormState,
88 FormSubscription,
9+ FormValuesShape,
910 FieldSubscription,
1011 FieldValidator
1112} from 'final-form'
1213
1314type SupportedInputs = 'input' | 'select' | 'textarea'
1415
15- export type ReactContext = {
16- reactFinalForm: FormApi
16+ export type ReactContext<FormValues: FormValuesShape> = {
17+ reactFinalForm: FormApi<FormValues>
1718}
1819
1920export type FieldInputProps = {
@@ -49,27 +50,27 @@ export type FieldRenderProps = {
4950 }
5051}
5152
52- export type FormRenderProps = {
53+ export type FormRenderProps<FormValues: FormValuesShape> = {
5354 handleSubmit: (?SyntheticEvent<HTMLFormElement>) => ?Promise<?Object>,
54- form: FormApi
55- } & FormState
55+ form: FormApi<FormValues>
56+ } & FormState<FormValues>
5657
57- export type FormSpyRenderProps = {
58- form: FormApi
59- } & FormState
58+ export type FormSpyRenderProps<FormValues: FormValuesShape> = {
59+ form: FormApi<FormValues>
60+ } & FormState<FormValues>
6061
6162export type RenderableProps<T> = {
6263 component?: React.ComponentType<*> | SupportedInputs,
6364 children?: ((props: T) => React.Node) | React.Node,
6465 render?: (props: T) => React.Node
6566}
6667
67- export type FormProps = {
68+ export type FormProps<FormValues: FormValuesShape> = {
6869 subscription?: FormSubscription,
69- decorators?: Decorator[],
70+ decorators?: Decorator<FormValues> [],
7071 initialValuesEqual?: (?Object, ?Object) => boolean
71- } & Config &
72- RenderableProps<FormRenderProps>
72+ } & Config<FormValues> &
73+ RenderableProps<FormRenderProps<FormValues> >
7374
7475export type UseFieldConfig = {
7576 afterSubmit?: () => void,
@@ -95,14 +96,16 @@ export type FieldProps = UseFieldConfig & {
9596 name: string
9697} & RenderableProps<FieldRenderProps>
9798
98- export type UseFormStateParams = {
99- onChange?: (formState: FormState) => void,
99+ export type UseFormStateParams<FormValues: FormValuesShape> = {
100+ onChange?: (formState: FormState<FormValues> ) => void,
100101 subscription?: FormSubscription
101102}
102103
103- export type FormSpyProps = UseFormStateParams &
104- RenderableProps<FormSpyRenderProps>
104+ export type FormSpyProps<
105+ FormValues: FormValuesShape
106+ > = UseFormStateParams<FormValues> &
107+ RenderableProps<FormSpyRenderProps<FormValues>>
105108
106- export type FormSpyPropsWithForm = {
107- reactFinalForm: FormApi
108- } & FormSpyProps
109+ export type FormSpyPropsWithForm<FormValues: FormValuesShape> = {
110+ reactFinalForm: FormApi<FormValues>
111+ } & FormSpyProps<FormValues>
0 commit comments