conf
conf copied to clipboard
onDidChange doesn't support dot-notation for nested properties
I get a typescript compilation error when I try to pass in a key with dot-notation to the onDidChange
method. This seems to happen because the type of key the onDidChange method is expecting is keyof <StoreType>
. This doesn't include the nested object properties.
Requesting to add an overload that takes a key of type string
. Just like the get
or set
.
Thanks!
interface Config {
foo: Foo;
};
interface Foo {
bar: string;
};
export const defaults: Config = {
foo: {
bar: "foobar"
}
};
const store = new Store<Config>({
defaults,
});
// ERROR - Argument of type '"foo.bar"' is not assignable to parameter of type 'keyof Config'.
store.onDidChange('foo.bar', (nVal, oVal) => {
console.log(nVal, oVal);
});