Description
React-Redux v8 currently has a DefaultRootState
type defined:
Lines 13 to 23 in 4d38402
This was copy-pasted directly from the @types/react-redux
types in DefinitelyTyped, which have had that for a while.
We Redux maintainers were not involved in that type being added originally, and specifically think it's a bad practice:
Or to say it bluntly: If at that point in time, we as Redux maintainers would have known about what was going on in DefinitelyTyped, we would have prevented
DefaultRootState
from ever being added. Unfortunately, at that point we were not aware.It is a global enhancement of the state, no matter if the reducer was actually added to your store.
At one point in time, some library will go ahead and pollute that interface and suddenly every project using that library will have an extra property in their Redux store - without any reducer for it being present.
There is a good reason we don't recommend doing this anywhere in the docs.
Given that, I'd like to propose removing it from the v8 typings before this gets released.
I'm assuming we'd want to replace that with unknown
instead.
I did a couple code searches, and I see maybe 1000-1500 usages in the wild:
- https://sourcegraph.com/search?q=context:global+lang:typescript+DefaultRootState+count:2000&patternType=literal
- https://github.com/search?l=TypeScript&q=DefaultRootState&type=Code
- https://cs.github.com/?q=DefaultRootState
So that's not zero, but it isn't a thing that would completely break the ecosystem in the upgrade process.
Lenz also said that this is a pattern that could get replicated in userspace if desired, although I'm not sure what the details are on that.