@@ -11,11 +11,12 @@ interface ReactFieldApi<
11
11
TFormValidator extends
12
12
| Validator < TParentData , unknown >
13
13
| undefined = undefined ,
14
+ TParentMetaExtension extends object = never ,
14
15
> {
15
16
/**
16
17
* A pre-bound and type-safe sub-field component using this field as a root.
17
18
*/
18
- Field : FieldComponent < TParentData , TFormValidator >
19
+ Field : FieldComponent < TParentData , TFormValidator , TParentMetaExtension >
19
20
}
20
21
21
22
/**
@@ -28,6 +29,7 @@ export type UseField<
28
29
TFormValidator extends
29
30
| Validator < TParentData , unknown >
30
31
| undefined = undefined ,
32
+ TParentMetaExtension extends object = never ,
31
33
> = <
32
34
TName extends DeepKeys < TParentData > ,
33
35
TFieldValidator extends
@@ -36,10 +38,24 @@ export type UseField<
36
38
TData extends DeepValue < TParentData , TName > = DeepValue < TParentData , TName > ,
37
39
> (
38
40
opts : Omit <
39
- UseFieldOptions < TParentData , TName , TFieldValidator , TFormValidator , TData > ,
41
+ UseFieldOptions <
42
+ TParentData ,
43
+ TName ,
44
+ TFieldValidator ,
45
+ TFormValidator ,
46
+ TData ,
47
+ TParentMetaExtension
48
+ > ,
40
49
'form'
41
50
> ,
42
- ) => FieldApi < TParentData , TName , TFieldValidator , TFormValidator , TData >
51
+ ) => FieldApi <
52
+ TParentData ,
53
+ TName ,
54
+ TFieldValidator ,
55
+ TFormValidator ,
56
+ TData ,
57
+ TParentMetaExtension
58
+ >
43
59
44
60
/**
45
61
* A hook for managing a field in a form.
@@ -57,13 +73,15 @@ export function useField<
57
73
| Validator < TParentData , unknown >
58
74
| undefined = undefined ,
59
75
TData extends DeepValue < TParentData , TName > = DeepValue < TParentData , TName > ,
76
+ TParentMetaExtension extends object = never ,
60
77
> (
61
78
opts : UseFieldOptions <
62
79
TParentData ,
63
80
TName ,
64
81
TFieldValidator ,
65
82
TFormValidator ,
66
- TData
83
+ TData ,
84
+ TParentMetaExtension
67
85
> ,
68
86
) {
69
87
const [ fieldApi ] = useState ( ( ) => {
@@ -73,7 +91,8 @@ export function useField<
73
91
name : opts . name ,
74
92
} )
75
93
76
- const extendedApi : typeof api & ReactFieldApi < TParentData , TFormValidator > =
94
+ const extendedApi : typeof api &
95
+ ReactFieldApi < TParentData , TFormValidator , TParentMetaExtension > =
77
96
api as never
78
97
79
98
extendedApi . Field = Field as never
@@ -207,4 +226,6 @@ export const Field = (<
207
226
[ children , fieldApi , fieldApi . state . value , fieldApi . state . meta ] ,
208
227
)
209
228
return ( < > { jsxToDisplay } </ > ) as never
210
- } ) satisfies FunctionComponent < FieldComponentProps < any , any , any , any , any > >
229
+ } ) satisfies FunctionComponent <
230
+ FieldComponentProps < any , any , any , any , any , any >
231
+ >
0 commit comments