Struggling to find the correct typings for the createSelector res parameter from redux-js, especially in TypeScript where there are no examples or explanations available. The only guidance is provided in JS.
const selectFacts = React.useMemo(() => {
return createSelector(
(res) => res.data,
(data) => (data ? pick(data, facts_keys) : undefined)
);
}, []);
const { facts } = useGetProfileQuery(user?.email ?? skipToken, {
selectFromResult: (result) => ({
...result,
facts: selectFacts(result),
}),
});
Referenced here: https://redux.js.org/tutorials/essentials/part-8-rtk-query-advanced#selecting-values-from-results
If anyone has encountered a similar issue of unclear typing in TypeScript, please share your experience.
I resorted to type assertion as a temporary solution to avoid type definition errors, but this is not an ideal approach. Open to any alternative suggestions.