@@ -32,7 +32,7 @@ export type FormPropType<T extends () => Form> = PropType<
3232 ReturnType < T > & { $key ?: number }
3333> ;
3434
35- class Field < T , U extends T = T > {
35+ class Field < T > {
3636 private readonly $_valueRef : Ref < T > ;
3737 private readonly $_errorRef : ComputedRef < yup . ValidationError | undefined > ;
3838 public readonly $label : string ;
@@ -88,6 +88,8 @@ class Field<T, U extends T = T> {
8888 }
8989}
9090
91+ type FieldWithPreferredType < T , U extends T > = Field < T > ;
92+
9193class PrivateField < T > extends Field < T > {
9294 // Distinguish between Field and PrivateField in the structural type system
9395 private readonly $_isPrivateField ! : true ;
@@ -214,12 +216,12 @@ export function field<T>(
214216 value : T | Ref < T > ,
215217 schema ?: FieldSchema ,
216218 validateOptions ?: ValidateOptions
217- ) : Field < T , T > ;
219+ ) : Field < T > ;
218220export function field < T , U extends T > (
219221 value : T | Ref < T > ,
220222 schema ?: FieldSchema ,
221223 validateOptions ?: ValidateOptions
222- ) : Field < T , U > ;
224+ ) : FieldWithPreferredType < T , U > ;
223225export function field < T > (
224226 value : T | Ref < T > ,
225227 schema ?: FieldSchema ,
@@ -278,8 +280,8 @@ type ToObjectOutput<T extends Form> = {
278280 ? never
279281 : K ] : T [ K ] extends Form
280282 ? ToObjectOutput < T [ K ] >
281- : T [ K ] extends Field < any , infer U >
282- ? U
283+ : T [ K ] extends FieldWithPreferredType < infer U1 , infer U2 >
284+ ? U2
283285 : T [ K ] extends FormsField < infer U >
284286 ? ToObjectOutput < ReturnType < U > > [ ]
285287 : never ;
0 commit comments