@tanstack/form-core 1.24.4 → 1.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/FormApi.ts CHANGED
@@ -618,7 +618,7 @@ export type BaseFormState<
618
618
  /**
619
619
  * A record of field metadata for each field in the form, not including the derived properties, like `errors` and such
620
620
  */
621
- fieldMetaBase: Record<DeepKeys<TFormData>, AnyFieldMetaBase>
621
+ fieldMetaBase: Partial<Record<DeepKeys<TFormData>, AnyFieldMetaBase>>
622
622
  /**
623
623
  * A boolean indicating if the form is currently in the process of being submitted after `handleSubmit` is called.
624
624
  *
@@ -733,7 +733,7 @@ export type DerivedFormState<
733
733
  /**
734
734
  * A record of field metadata for each field in the form.
735
735
  */
736
- fieldMeta: Record<DeepKeys<TFormData>, AnyFieldMeta>
736
+ fieldMeta: Partial<Record<DeepKeys<TFormData>, AnyFieldMeta>>
737
737
  }
738
738
 
739
739
  export interface FormState<
@@ -924,8 +924,22 @@ export class FormApi<
924
924
  TOnServer
925
925
  >
926
926
  >
927
- fieldMetaDerived!: Derived<Record<DeepKeys<TFormData>, AnyFieldMeta>>
928
- store!: Derived<
927
+ fieldMetaDerived: Derived<
928
+ FormState<
929
+ TFormData,
930
+ TOnMount,
931
+ TOnChange,
932
+ TOnChangeAsync,
933
+ TOnBlur,
934
+ TOnBlurAsync,
935
+ TOnSubmit,
936
+ TOnSubmitAsync,
937
+ TOnDynamic,
938
+ TOnDynamicAsync,
939
+ TOnServer
940
+ >['fieldMeta']
941
+ >
942
+ store: Derived<
929
943
  FormState<
930
944
  TFormData,
931
945
  TOnMount,
@@ -1019,7 +1033,7 @@ export class FormApi<
1019
1033
 
1020
1034
  let originalMetaCount = 0
1021
1035
 
1022
- const fieldMeta = {} as FormState<
1036
+ const fieldMeta: FormState<
1023
1037
  TFormData,
1024
1038
  TOnMount,
1025
1039
  TOnChange,
@@ -1031,7 +1045,7 @@ export class FormApi<
1031
1045
  TOnDynamic,
1032
1046
  TOnDynamicAsync,
1033
1047
  TOnServer
1034
- >['fieldMeta']
1048
+ >['fieldMeta'] = {}
1035
1049
 
1036
1050
  for (const fieldName of Object.keys(
1037
1051
  currBaseStore.fieldMetaBase,
@@ -1652,7 +1666,6 @@ export class FormApi<
1652
1666
  for (const field of Object.keys(
1653
1667
  this.state.fieldMeta,
1654
1668
  ) as DeepKeys<TFormData>[]) {
1655
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1656
1669
  if (this.baseStore.state.fieldMetaBase[field] === undefined) {
1657
1670
  continue
1658
1671
  }
@@ -1860,7 +1873,6 @@ export class FormApi<
1860
1873
  for (const field of Object.keys(
1861
1874
  this.state.fieldMeta,
1862
1875
  ) as DeepKeys<TFormData>[]) {
1863
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1864
1876
  if (this.baseStore.state.fieldMetaBase[field] === undefined) {
1865
1877
  continue
1866
1878
  }
@@ -2215,15 +2227,15 @@ export class FormApi<
2215
2227
  * resets every field's meta
2216
2228
  */
2217
2229
  resetFieldMeta = <TField extends DeepKeys<TFormData>>(
2218
- fieldMeta: Record<TField, AnyFieldMeta>,
2219
- ): Record<TField, AnyFieldMeta> => {
2230
+ fieldMeta: Partial<Record<TField, AnyFieldMeta>>,
2231
+ ): Partial<Record<TField, AnyFieldMeta>> => {
2220
2232
  return Object.keys(fieldMeta).reduce(
2221
- (acc: Record<TField, AnyFieldMeta>, key) => {
2233
+ (acc, key) => {
2222
2234
  const fieldKey = key as TField
2223
2235
  acc[fieldKey] = defaultFieldMeta
2224
2236
  return acc
2225
2237
  },
2226
- {} as Record<TField, AnyFieldMeta>,
2238
+ {} as Partial<Record<TField, AnyFieldMeta>>,
2227
2239
  )
2228
2240
  }
2229
2241