While transferring js typescript, I encountered a problem. The function below is designed to work with two different types of data, but I am seeing this error:
Property 'dateTime' does not exist on type 'Operation | OperationCreated'.
Property 'dateTime' does not exist on type 'OperationCreated'
type DateTime = {
date: string;
};
type Operation = {
dateTime: DateTime;
};
type OperationCreated = {
createdDate: string;
};
const sortByDate = (o1: Operation | OperationCreated, o2: Operation | OperationCreated) =>
stringToMillisecond(o1.createdDate || o1.dateTime.date) - stringToMillisecond(o2.createdDate || o2.dateTime.date);
Just taking the initial steps in typescript, any help would be appreciated