I'm looking for a solution that provides strongly typed code. The problem arises when trying to implement solutions from a related question - Min/Max of dates in an array? - as it results in an error.
TS2345: Argument of type 'Date' is not assignable to parameter of type 'number'.
Here's the snippet of my code:
const min: Date = Math.min(begin as Date, (end || defaultDate) as Date);
const max: Date = Math.max(begin as Date, (end || defaultDate) as Date);
The part where I use begin as Date
is being highlighted with an underline.
Could someone provide guidance on how to correctly find the minimum and maximum dates in Typescript?