Write a TypeScript function that accepts two dates as input and calculates the number of days between them. The function should return a negative value if the second date is earlier than the first date.
PLAINFORMAT
function daysBetweenDates(date1: Date, date2: Date): number {
  // Calculate the difference in milliseconds
  const diffInMilliseconds = date2.getTime() - date1.getTime();

  // Convert milliseconds to days (1000 ms * 60 s * 60 min * 24 hours)
  const diffInDays = diffInMilliseconds / (1000 * 60 * 60 * 24);

  return Math.round(diffInDays);
}