store.commit('UPDATE_FILTERS', { key: 'search', value: 'foo' }) // Working, as expected
store.commit('UPDATE_FILTERS', { key: 'search', value: 4 }) // Fail, of course
store.commit('UPDATE_FILTERS', { key: 'search', value: true }) // Does not fail even if it should 😞
It seems that the union of all possible types is inferred, so here value can be string or boolean, instead of being specific to the key used.
But TypeScript should be able to handle this situation correctly.
It does work with a standard function:
Hey, thanks for your awesome lib!
When using generics in mutations (and actions too), lookup types are not inferred as accurately as they could be.
Here is my store definition:
And when I use the mutation in a component:
It seems that the union of all possible types is inferred, so here
value
can bestring
orboolean
, instead of being specific to the key used.But TypeScript should be able to handle this situation correctly. It does work with a standard function:
Is it something that can be improved? :slightly_smiling_face: