Unresolvable javascript:S7766 when using Date arguments

Hello, I have a problem with the following javascript code:

/**
 * Get the most recent date from the given array.
 *
 * @param { Date[] } dates
 * @returns { Date }
 */
function getMostRecentDate(dates)
{
    return dates.reduce(
        (mostRecent, current) => mostRecent < current ? current : mostRecent,
        new Date(1970, 1, 1, 0, 0, 0)
    );
}

This triggers a javascript:S7766 on the ternary use, suggesting to replace it with Math.max

Unfortunately, there are no overloads for Math.max that accept a Date argument which in turns leads to type errors, preventing me from releasing this code.

This happens with Developer Edition v2026.1.2 (121356)

For now, I have “accepted” it as safe, but it would be nice if this was not coming up in the first place.

Hi @obones,

It’s great to hear from you again, and thank you for the detailed report! This is indeed a false positive, the suggested Math.max(...) replacement is not valid here because your reducer is selecting Date objects, while Math.max returns a number.

We’ve created JS-1908 to track the fix.
Thanks again for taking the time to report this, feedback like yours helps us make the tool better!

François