refactor: improve type safety (#155)

* Fix to make it type safe.

* The build is failing, fix it.
This commit is contained in:
Katsuyuki Karasawa
2024-08-28 01:19:26 +09:00
committed by GitHub
parent f79ee3482d
commit e9c8930559
10 changed files with 489 additions and 133 deletions

View File

@@ -1,20 +1,20 @@
import type { LIGHT_DARK_MODE } from '@/types/config'
import {
AUTO_MODE,
DARK_MODE,
DEFAULT_THEME,
LIGHT_MODE,
} from '@constants/constants.ts'
import type { LIGHT_DARK_MODE } from '@/types/config'
export function getDefaultHue(): number {
const fallback = '250'
const configCarrier = document.getElementById('config-carrier')
return parseInt(configCarrier?.dataset.hue || fallback)
return Number.parseInt(configCarrier?.dataset.hue || fallback)
}
export function getHue(): number {
const stored = localStorage.getItem('hue')
return stored ? parseInt(stored) : getDefaultHue()
return stored ? Number.parseInt(stored) : getDefaultHue()
}
export function setHue(hue: number): void {