In my function, I am attempting to standardize certain values by specifying the whole function type as Partial. However, despite declaring the interaction variable as Partial Type, I keep encountering the error message saying "Cannot read property endTime
of undefined."
Below is the code snippet for my function:
export function mapOptionsToEditActivity<T extends InteractionType>(
interaction: Partial<InteractionTypeInteractionMap[T]>,
interactionType: T,
matchedRecord: InteractionMatchedRecord,
user: User,
activityId: string,
): Partial<CrmInteraction> {
const mappedInteraction = {
crmCallId: activityId,
dateEnd: interaction.endTime,
dateStart: interaction.startTime,
userCrmId: user.crmId,
};
return mappedInteraction;
}
The above code clearly indicates that I have defined interaction as Partial Type and the entire function type as Partial as well.
Nevertheless, the issue persists with the following error message:
Cannot read property endTime of undefined
I would greatly appreciate any assistance in pinpointing where the mistake might be occurring.