Skip to content

Commit 367d9b4

Browse files
feat(store): use variadic tuple types for createSelector (#3023)
Closes #2715 BREAKING CHANGES: When manually specifying the generic arguments, you have to specify the selector's list of selector return values. BEFORE: ```ts createSelector<Story[], Story[], Story[][]> ``` AFTER: ```ts // needs to be a tuple 👇 createSelector<Story[], [ Story[] ] , Story[][]> ```
1 parent 52b828e commit 367d9b4

File tree

4 files changed

+109
-234
lines changed

4 files changed

+109
-234
lines changed

modules/entity/src/state_selectors.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ export function createSelectorsFactory<T>() {
1414
const selectAll = createSelector(
1515
selectIds,
1616
selectEntities,
17-
(ids: T[], entities: Dictionary<T>): any =>
18-
ids.map((id: any) => (entities as any)[id])
17+
(ids, entities): any => ids.map((id: any) => (entities as any)[id])
1918
);
2019

2120
const selectTotal = createSelector(selectIds, (ids) => ids.length);

modules/store/spec/selector.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ describe('Selectors', () => {
128128
const selectorFn = jasmine
129129
.createSpy(
130130
'selectorFn',
131-
createSelector((state) => state, projectorFn)
131+
createSelector((state: any) => state, projectorFn)
132132
)
133133
.and.callThrough();
134134

0 commit comments

Comments
 (0)