-
Notifications
You must be signed in to change notification settings - Fork 668
Closed
Labels
Milestone
Description
Hi, I'm trying to create selectorFactoryFactories however am having trouble with the types and was wondering if there's something I'm missing, or if it's a bug, or if it's impossible. Any and all help would be appreciated.
Edit* The destructuring method works perfectly during runtime, the issue is with the type errors being thrown.
The below case works as expected.
createSelector([
regularSelectorA,
selectorFactory('B'),
selectorFactory('C'),
],
(a, b, c ) => return { a, b, c })
However when I destructure part of the array or the complete array, typescript complains.
createSelector(...[
regularSelectorA,
selectorFactory('B'),
selectorFactory('C'),
],
(a, b, c ) => return { a, b, c })
In the above case typescript errors with expected 2-13 arguments but got 1 or more
createSelector([
regularSelectorA,
...selectorFactoryFactory('B', 'C')
],
(a, b, c ) => return { a, b, c })
In the above typescript also errors with
Argument of type '(OutputSelector<SharedRootState, ReadonlyRecord...' is not assignable to parameter of type '[ParametricSelector<SharedRootState, {}, ReadonlyRecord"...'.
Property '0' is missing in type '(OutputSelector<SharedRootState, ReadonlyRecord<BaseEntity
The definition for selectorFactory
and selectorFactoryFactory
and regularSelector
function regularSelector(state: RootState) { return state.slice }
const selectorFactory= (attribute) => {
return createSelector(regularSelector, function (storeState) {
return storeState && storeState[attribute];
});
}
const selectorFactoryFactory = (...attributes) => {
return attributes.map(att => selectorFactory(att)
}
jsprds, ArekRado, adrienj, tom-odb, atzcl and 6 more