Is it possible to dynamically assign value types in the
const set = (key: keyof Store, value: any)
function based on the keys defined in the Store
interface? For instance, setting a key foo
as type number
and key bar
as type string[]
.
import store from "electron-store"
interface Store {
foo: number
bar: string[]
}
const schema = {
foo: {
type: "number",
},
bar: {
type: "array",
items: {
type: "string",
},
},
} as const
const config = new store<Store>({
schema: schema,
})
const set = (key: keyof Store, value: any) => {
return config.set(key, value)
}