what is the best way to achieve the following:
export interface Iabc {
startDate: Date | string | null;
endDate: Date | string | null;
nestedSection: {
a: string | null;
b: boolean | null;
c: boolean | null;
d: Date | string | null;
};
}
Currently I am converting the Dates contained in the nested sections like so
nestedSection: Object.entries(values.nestedSection).reduce((prev, [k, v]) => {
if (v instanceof Date) {
return {
...prev,
[k]: moment(v).format('YYYY-MM-DD'),
};
}
return prev;
}, values.nestedSection),
However I need to do it for startDate and endDate a level up from the nested section. TIA