There is a problem with TS:
An error occurs stating that 'parsedHours' and 'parsedMinutes' should be declared as constants by using 'const' instead of 'prefer-const'.
This issue arises when attempting to destructure an array after performing a string split operation:
let [
parsedHours = '00',
parsedMinutes = '00',
parsedSeconds = '00',
parsedMillis = '000'
] = "12:34:56".split(':');
if (parsedSeconds.includes('.')) {
[parsedSeconds, parsedMillis] = parsedSeconds.split('.');
}
Hours and minutes are recommended to be declared as constants, but seconds and millis can change so they should remain as let variables. There are several ways to address this issue, but finding an elegant solution has been challenging.
Any suggestions?