@@ -37,7 +37,6 @@ import {
3737 FieldState ,
3838 GenericFormValues ,
3939 TypedSchema ,
40- YupSchema ,
4140} from './types' ;
4241import {
4342 getFromPath ,
@@ -69,7 +68,7 @@ export interface FormOptions<
6968 | TypedSchema < TValues , TOutput >
7069> {
7170 validationSchema ?: MaybeRef < TSchema extends TypedSchema ? TypedSchema < TValues , TOutput > : any > ;
72- initialValues ?: MaybeRef < TValues > ;
71+ initialValues ?: MaybeRef < Partial < TValues > > ;
7372 initialErrors ?: Record < keyof TValues , string | undefined > ;
7473 initialTouched ?: Record < keyof TValues , boolean > ;
7574 validateOnMount ?: boolean ;
@@ -865,7 +864,7 @@ export function useForm<
865864function useFormMeta < TValues extends Record < string , unknown > > (
866865 fieldsByPath : Ref < FieldPathLookup < TValues > > ,
867866 currentValues : TValues ,
868- initialValues : MaybeRef < TValues > ,
867+ initialValues : MaybeRef < Partial < TValues > > ,
869868 errors : Ref < FormErrors < TValues > >
870869) {
871870 const MERGE_STRATEGIES : Record < keyof Pick < FieldMeta < unknown > , 'touched' | 'pending' | 'valid' > , 'every' | 'some' > = {
@@ -899,7 +898,7 @@ function useFormMeta<TValues extends Record<string, unknown>>(
899898
900899 return computed ( ( ) => {
901900 return {
902- initialValues : unref ( initialValues ) as TValues ,
901+ initialValues : unref ( initialValues ) as Partial < TValues > ,
903902 ...flags ,
904903 valid : flags . valid && ! keysOf ( errors . value as any ) . length ,
905904 dirty : isDirty . value ,
@@ -918,13 +917,13 @@ function useFormInitialValues<TValues extends GenericFormValues>(
918917 const values = resolveInitialValues ( opts ) ;
919918 const providedValues = opts ?. initialValues ;
920919 // these are the mutable initial values as the fields are mounted/unmounted
921- const initialValues = ref < TValues > ( values ) ;
920+ const initialValues = ref < Partial < TValues > > ( values ) ;
922921 // these are the original initial value as provided by the user initially, they don't keep track of conditional fields
923922 // this is important because some conditional fields will overwrite the initial values for other fields who had the same name
924923 // like array fields, any push/insert operation will overwrite the initial values because they "create new fields"
925924 // so these are the values that the reset function should use
926925 // these only change when the user explicitly changes the initial values or when the user resets them with new values.
927- const originalInitialValues = ref < TValues > ( deepCopy ( values ) ) ;
926+ const originalInitialValues = ref < Partial < TValues > > ( deepCopy ( values ) ) as Ref < Partial < TValues > > ;
928927
929928 function setInitialValues ( values : Partial < TValues > , updateFields = false ) {
930929 initialValues . value = deepCopy ( values ) ;
0 commit comments