Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
KeyValue Storage
type KeyValueStorage = {
'setting1': boolean;
'setting2': string;
'setting3': number;
/** all possible keys for the key-value storage */
type KeyValueStorageKey = keyof KeyValueStorage;
interface UserStorage {
/** set a value for a specific key */
set<T extends KeyValueStorageKey>(key: T, value: KeyValueStorage[T]): void;
/** get the value for a specific key. If not present return null*/
get<T extends KeyValueStorageKey>(key: T): KeyValueStorage[T] | null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment