Options type does not allow nested object or array keys
melink14 opened this issue · 3 comments
The typescript typing for Options
is:
export interface Options {
[key: string]: string | number | boolean;
}
However, my options object has a key which points to an array of objects. This is perfectly valid JSON so ideally should be accepted.
Such keys do cause a problem with the sync form capabilities of the package (which is one reason why I had to forgo that feature) but since that feature is optional it seems like it'd make sense to expand the type to all JSON safe types.
The form syncing is the main part of the package, hence the name. I’d rather not suggest that JSON is supported while it’s not supported by the form syncing.
I always assumed the sync was related to chrome.storage.sync
vs form autosave/load but I agree that if we did want something like that it'd need some way of letting the user know the difference (maybe different method or special type that must be opted in).
Either way, JS extensions will never know anything is different since they won't see the types so it seems like it might be tractable if there's a way to loosen the types while also making it clear that some types won't work for all features.
I was mostly drawn by the nice API abstraction with migrations and promises though I'm sure the current implementation works for 99% of people!
(If it seems intractable we can close this since might be too much a special case; right now I'm using ugly type coercion to let the migrations run.)
Yeah the module is an all-in-one to manage the options, especially for the form autosave part, which are a good chunk of the package size as well.