debugging of tsc errors

This commit is contained in:
2023-03-05 02:27:15 +01:00
parent 77c3b90d02
commit 1906ac1981
2 changed files with 12 additions and 5 deletions

View File

@@ -21,12 +21,12 @@ export const qs = (
selector: string | keyof HTMLElementTagNameMap,
parent = document
): Element => {
return parent.querySelector(selector)
return parent.querySelector(selector) as unknown as Element
}
export const qsa = (
selector: string | keyof HTMLElementTagNameMap,
parent = document
): Element[] => {
return [...parent.querySelectorAll(selector)]
): NodeListOf<Element> => {
return parent.querySelectorAll(selector)
}

View File

@@ -69,12 +69,19 @@ export const formatRelativeDate = (
numeric: 'auto'
})
let duration = (toDate - fromDate) / 1000
let output = ''
for (let i = 0; i <= DIVISIONS.length; i++) {
const division = DIVISIONS[i]
if (Math.abs(duration) < division.amount)
return RELATIVE_DATE_FORMATTER.format(Math.round(duration), division.name)
if (Math.abs(duration) < division.amount) {
output = RELATIVE_DATE_FORMATTER.format(
Math.round(duration),
division.name
)
}
duration /= division.amount
}
return output
}