Skip to content

Commit

Permalink
feat(store): use variadic tuple types for createSelector (#3023)
Browse files Browse the repository at this point in the history
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[][]>
```
  • Loading branch information
david-shortman authored Nov 11, 2021
1 parent 52b828e commit 367d9b4
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 234 deletions.
3 changes: 1 addition & 2 deletions modules/entity/src/state_selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export function createSelectorsFactory<T>() {
const selectAll = createSelector(
selectIds,
selectEntities,
(ids: T[], entities: Dictionary<T>): any =>
ids.map((id: any) => (entities as any)[id])
(ids, entities): any => ids.map((id: any) => (entities as any)[id])
);

const selectTotal = createSelector(selectIds, (ids) => ids.length);
Expand Down
2 changes: 1 addition & 1 deletion modules/store/spec/selector.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('Selectors', () => {
const selectorFn = jasmine
.createSpy(
'selectorFn',
createSelector((state) => state, projectorFn)
createSelector((state: any) => state, projectorFn)
)
.and.callThrough();

Expand Down
Loading

0 comments on commit 367d9b4

Please sign in to comment.