refactor(web): improve storage utility type safety with function overloads

Add function overloads to getNumber and getBoolean so they return
non-nullable types when a defaultValue is provided. This eliminates
the need for non-null assertions at call sites.

- Remove unused persist-config.ts (zustand adapter not needed)
- Remove ! assertions from layout-slice.ts
This commit is contained in:
yyh
2026-01-18 16:10:04 +08:00
parent b75b7d6c61
commit 70bea85624
3 changed files with 8 additions and 12 deletions

View File

@ -73,6 +73,8 @@ function remove(key: string): void {
}
}
function getNumber(key: string): number | null
function getNumber(key: string, defaultValue: number): number
function getNumber(key: string, defaultValue?: number): number | null {
const value = get<string | number>(key)
if (value === null)
@ -82,6 +84,8 @@ function getNumber(key: string, defaultValue?: number): number | null {
return Number.isNaN(parsed) ? (defaultValue ?? null) : parsed
}
function getBoolean(key: string): boolean | null
function getBoolean(key: string, defaultValue: boolean): boolean
function getBoolean(key: string, defaultValue?: boolean): boolean | null {
const value = get<string | boolean>(key)
if (value === null)