@@ -8,7 +8,13 @@ import type {
8
8
FormOptions ,
9
9
FormValidateOrFn ,
10
10
} from '@tanstack/form-core'
11
- import type { Accessor , Component , Context , JSX , ParentProps } from 'solid-js'
11
+ import type {
12
+ Accessor ,
13
+ Component ,
14
+ Context ,
15
+ JSXElement ,
16
+ ParentProps ,
17
+ } from 'solid-js'
12
18
import type { FieldComponent } from './createField'
13
19
import type { SolidFormExtendedApi } from './createForm'
14
20
@@ -51,8 +57,8 @@ type UnwrapDefaultOrAny<DefaultT, T> = [DefaultT] extends [T]
51
57
52
58
export function createFormHookContexts ( ) {
53
59
// We should never hit the `null` case here
54
- const fieldContext = createContext < AnyFieldApi > (
55
- null as unknown as AnyFieldApi ,
60
+ const fieldContext = createContext < Accessor < AnyFieldApi > > (
61
+ null as unknown as Accessor < AnyFieldApi > ,
56
62
)
57
63
58
64
function useFieldContext < TData > ( ) {
@@ -65,26 +71,28 @@ export function createFormHookContexts() {
65
71
)
66
72
}
67
73
68
- return field as FieldApi <
69
- any ,
70
- string ,
71
- TData ,
72
- any ,
73
- any ,
74
- any ,
75
- any ,
76
- any ,
77
- any ,
78
- any ,
79
- any ,
80
- any ,
81
- any ,
82
- any ,
83
- any ,
84
- any ,
85
- any ,
86
- any ,
87
- any
74
+ return field as Accessor <
75
+ FieldApi <
76
+ any ,
77
+ string ,
78
+ TData ,
79
+ any ,
80
+ any ,
81
+ any ,
82
+ any ,
83
+ any ,
84
+ any ,
85
+ any ,
86
+ any ,
87
+ any ,
88
+ any ,
89
+ any ,
90
+ any ,
91
+ any ,
92
+ any ,
93
+ any ,
94
+ any
95
+ >
88
96
>
89
97
}
90
98
@@ -124,7 +132,7 @@ interface CreateFormHookProps<
124
132
TFormComponents extends Record < string , Component < any > > ,
125
133
> {
126
134
fieldComponents : TFieldComponents
127
- fieldContext : Context < AnyFieldApi >
135
+ fieldContext : Context < Accessor < AnyFieldApi > >
128
136
formComponents : TFormComponents
129
137
formContext : Context < AnyFormApi >
130
138
}
@@ -218,7 +226,7 @@ export interface WithFormProps<
218
226
>
219
227
}
220
228
> ,
221
- ) => JSX . Element
229
+ ) => JSXElement
222
230
}
223
231
224
232
export function createFormHook <
@@ -280,7 +288,7 @@ export function createFormHook<
280
288
return (
281
289
< form . Field { ...fieldProps } >
282
290
{ ( field ) => (
283
- < opts . fieldContext . Provider value = { field ( ) } >
291
+ < opts . fieldContext . Provider value = { field } >
284
292
{ childProps . children ( Object . assign ( field , opts . fieldComponents ) ) }
285
293
</ opts . fieldContext . Provider >
286
294
) }
0 commit comments