Skip to content

Commit f564852

Browse files
refactor: migrate localStorage.js to TypeScript (#2255)
1 parent b0ede0f commit f564852

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/utils/localStorage.js renamed to src/utils/localStorage.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
export function setWithExpiry(key, value, ttl) {
1+
export function setWithExpiry(key: string, value: any, ttl: number) {
22
const item = {
3-
value: value,
3+
value,
44
expiry: new Date().getTime() + ttl
55
}
6+
67
localStorage.setItem(key, JSON.stringify(item))
78
}
89

9-
export function getWithExpiry(key) {
10+
export function getWithExpiry(key: string) {
1011
const itemString = window.localStorage.getItem(key)
1112
if (!itemString) return null
1213

0 commit comments

Comments
 (0)