Is there a way to specifically exclude the Date
type from being considered as part of the object
type? I am encountering an error in my form validation where the Date
type is causing issues within objects.
export type FieldErrors<FormValues> = {
[Key in keyof FormValues]?: FormValues[Key] extends any[]
? FormValues[Key][number] extends object
? FieldErrors<FormValues[Key][number]>[]
: FieldError
: FormValues[Key] extends object // this is the issue bit when extend object
? FieldErrors<FormValues[Key]>
: FieldError
};
type FormData = {
stringField: string;
numberField: string;
dateField: Date;
};
{errors.dateField && errors.dateField.message} // This results in an error because Date type is considered an object