Skip to content

Commit 9c19859

Browse files
committed
feat: storage key 타입 추가
1 parent ec5b624 commit 9c19859

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/types/todo.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export interface TodoItem {
2+
export type StorageKey = "todo" | "count";
3+
24
text: string;
35
isCompleted: boolean;
46
}

src/utils/storage.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { StorageKey } from "../types/todo";
2+
13
const storage = window.localStorage;
24

35
export const setItem = (key: string, value: string) => {
@@ -9,7 +11,7 @@ export const setItem = (key: string, value: string) => {
911
}
1012
};
1113

12-
export const getItem = <T>(key: string, defaultValue: T): T => {
14+
export const getItem = <T>(key: StorageKey, defaultValue: T): T => {
1315
try {
1416
const data = storage.getItem(key);
1517
if (data) return JSON.parse(data);

0 commit comments

Comments
 (0)