Design comparison
SolutionDesign
Solution retrospective
First time using typescript, i still don't know which one should i give a type. like, should i create an interface for an array which used for localStorage and svelte store. And this is what i do, is there any tips on how to build a localStorage with svelte store and typescript?
import { writable } from 'svelte/store';
const storedLinks =
JSON.parse(localStorage.getItem('linkStorage') || 'null') || [];
export const links = writable<string[]>(storedLinks);
links.subscribe((value) => (localStorage.linkStorage = JSON.stringify(value)));
Community feedback
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord