T
TanStack3w ago
fascinating-indigo

Error with Moment type

Hi, do you know why when i adding moment type in my
SortedFormValues
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;
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
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.
1 Reply
ratty-blush
ratty-blush3w ago
moment uses recursive types I think, so that‘s why it breaks

Did you find this page helpful?