You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
when declaring my containers props i do something like this:
// In my selector file
const simpleSelector = (state: RootState): string => state.mydata;
const reselectSelector = createSelector([simpleSelector], (selector: string): string => selector);
// In my container file
interface SimpleContainerProps {
simpleSelector: typeof simpleSelector; // this is ok because type is string
reselectSelector: typeof reselectSelector; // this gives problems because type is 'OutputSelector<RootState, string, (selector: string) => string>'
}
This gives me the opportunity to be sure that if I change a selector used by any components on my app, typescript compiler will throw an error. However as you can see from my code's comments I cant use it for selectors created by reselect using createSelector.
Does anyone encountered this problem too?
The text was updated successfully, but these errors were encountered:
Digging to this issue I found that is a common problem in typescript, and even my first example (typeof simpleSelector) doesn't work, as the type is not string but (state: RootState) => string.
yes this is a limitation of TypeScript type system, I could only recommend this workaround which is similar to the returnof that you mentioned: https://github.com/piotrwitek/utility-types#call
Hi,
when declaring my containers props i do something like this:
This gives me the opportunity to be sure that if I change a selector used by any components on my app, typescript compiler will throw an error. However as you can see from my code's comments I cant use it for selectors created by reselect using createSelector.
Does anyone encountered this problem too?
The text was updated successfully, but these errors were encountered: