-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createSelector can't handle generic state #571
Comments
Noted, but unfortunately I'm not sure when I'm going to have time to look into this. |
This case doesn't work either: const createBazSelector = <S>(
getFoo: Selector<S, number, never>
): Selector<S, string, never> => createSelector(getFoo, (_state) => 'bar', (_foo, _bar) => 'baz') |
Is it ever going to be fixed? It's not a big deal now to stick with 4.1.2 if there are no new major versions but sooner or later... |
@mitoihs realistically, no. The current TS types are needed to deal with a lot of other concerns, like making sure the argument types are inferred correctly. It would be nice if they handled this generics issue, but if it comes down to "have correct argument types" vs "handle generic state", the arguments are more important. On top of that: I simply don't have time to look into this issue. Right now all my attention is focused on RTK 2.0. Now, as part of that I am starting to work on possible changes to the internals of Reselect for v5, but at the moment that does not include any planned work on the TS types. And, tbh, we have a very similar problem with So, it's likely that this problem isn't even "fixable" given the current structure of the TS types. If anyone else would like to try fixing this, please do so. But I don't have time or priority to work on this, and my guess is that there isn't a "fix" without coming up with a completely different set of TS types. |
@markerikson thank you for an honest reply. Could you elaborate a bit about |
I need a generic here, since I have shared functions that are used in several Apps with different RootStates.
I boiled it down to:
This works up until version 4.1.2. From 4.1.3 onwards the following TypeScript error happens:
Versions
TS: 4.6.2
Reselect: 4.1.5
The text was updated successfully, but these errors were encountered: