I ran into some typing issue with stores. I've got a component that expects a data: T[] and setter: SetStoreFunction<T[]> . This is all fine when passing in a complete store as created by createStore(...) but breaks down if I want to pass a part around:
e.g.
<Foo
data={store.foo}
setter={(...args) => setStore('foo', ...args)}
/>
While this does indeed work at runtime TS goes bonkers about this as is doesn't know the type of args and I can't deduce anything due to the overload of the SetStoreFunction interface.
fwiw. would be a helper like subStoreSetter(store, "foo") which returns that setter function so it could be used like that:
const setFoo = subStoreSetter(setStore, 'foo')
<Foo
data={store.foo}
setter={setFoo}
/>
While we're at it that feature could also be a member of the setStore function which would look really nice API wise:
const setFoo = setStore.sub('foo')
I don't know if this is even possible or if I should be replacing that one store object with multiple arrays into multiple stores one per array.
Maybe that feature is still around somewhere and I'm just not seeing it. 🙈