1
0

feat: type improvements

This commit is contained in:
Dominik Pschenitschni
2022-10-17 13:14:07 +02:00
parent 1002579173
commit 599e28e5e5
43 changed files with 162 additions and 135 deletions

View File

@ -10,7 +10,7 @@ const days = {
friday: 5,
saturday: 6,
sunday: 0,
}
} as Record<string, number>
for (const n in days) {
test(`today on a ${n}`, () => {
@ -32,7 +32,7 @@ const nextMonday = {
friday: 3,
saturday: 2,
sunday: 1,
}
} as Record<string, number>
for (const n in nextMonday) {
test(`next monday on a ${n}`, () => {
@ -48,7 +48,7 @@ const thisWeekend = {
friday: 1,
saturday: 0,
sunday: 0,
}
} as Record<string, number>
for (const n in thisWeekend) {
test(`this weekend on a ${n}`, () => {
@ -64,7 +64,7 @@ const laterThisWeek = {
friday: 0,
saturday: 0,
sunday: 0,
}
} as Record<string, number>
for (const n in laterThisWeek) {
test(`later this week on a ${n}`, () => {
@ -80,7 +80,7 @@ const laterNextWeek = {
friday: 7 + 0,
saturday: 7 + 0,
sunday: 7 + 0,
}
} as Record<string, number>
for (const n in laterNextWeek) {
test(`later next week on a ${n} (this week)`, () => {

View File

@ -1,4 +1,6 @@
export function calculateDayInterval(dateString: string, currentDay = (new Date().getDay())) {
type Day<T extends number = number> = T
export function calculateDayInterval(dateString: string, currentDay = (new Date().getDay())): Day {
switch (dateString) {
case 'today':
return 0

View File

@ -6,7 +6,7 @@
* @param dateString
* @returns {Date}
*/
export const createDateFromString = dateString => {
export function createDateFromString(dateString: string | Date) {
if (dateString instanceof Date) {
return dateString
}

View File

@ -8,7 +8,7 @@ import {i18n} from '@/i18n'
const locales = {en: enGB, de, ch: de, fr, ru}
export function dateIsValid(date) {
export function dateIsValid(date: Date | null) {
if (date === null) {
return false
}