TanStackT
TanStack3mo ago
1 reply
dangerous-fuchsia

Error with Moment type

Hi, do you know why when i adding moment type in my
SortedFormValues
he throw a error ?

Code :
import { useAppForm } from '@/context/FormContext';
import { Devis, Opportunity, PlanningTodo, Profile, Projet } from '@/utils/types/databaseTypes';
import { Moment } from 'moment';

interface SortedFormValuesTypes {
  projects: Projet | null;
  profiles: Profile | null;
  opportunities: Opportunity | null;
  todos: PlanningTodo | null;
  quotes: Devis | null;
  moment: {
    beginMoment: Moment | null;
    endMoment: Moment | null;
  };
}

const emptyValues: SortedFormValuesTypes = {
  projects: null,
  profiles: null,
  opportunities: null,
  todos: null,
  quotes: null,
  moment: {
    beginMoment: null,
    endMoment: null,
  },
};

export function useSortedForm() {
  return useAppForm({ defaultValues: emptyValues });
}

export type SortedFormType = ReturnType<typeof useSortedForm>;
export type SortedFormValues = typeof emptyValues;


Error :
Type error: Type instantiation is excessively deep and possibly infinite.

  69 |           </Grid>
  70 |           <Grid item xs={8} sm={4} md={2}>
> 71 |             <sortedForm.AppField name={'quotes'}>
     |             ^
  72 |               {field => (
  73 |                 <field.Autocomplete
  74 |                   label={'Sélectionnez un Devis'}
Next.js build worker exited with code: 1 and signal: null


This error does not appear if I change the moment type to string.
Was this page helpful?