-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EntityAdapter.getSelectors(selectState) has wrong typing #2751
Comments
Same pb here when trying to use the |
Is there anything we can do to help get this PR merged ? It would be nice to finally have those types fixed. |
Last time the ngrx team aimed to allow the overrideSelector to accept non memoized selector as well instead of adjusting the getSelectors. #2502 I hope someone can get it done this time - fingers crossed :) |
Hi, as mentioned in #2978 the docs don't link to the correct interface. |
Bump this issue for the documentation error. |
…parent selector Closes #2751, #3172 BREAKING CHANGES: Selectors returned by the `adapter.getSelectors` signature that accepts a parent selector are strongly typed. BEFORE: ```ts const { selectIds, // type: (state: object) => string[] | number[] selectEntities, // type: (state: object) => Dictionary<Book> selectAll, // type: (state: object) => Book[] selectTotal, // type: (state: object) => number } = adapter.getSelectors(selectBooksState); ``` AFTER: ```ts const { selectIds, // type: MemoizedSelector<object, string[] | number[]> selectEntities, // type: MemoizedSelector<object, Dictionary<Book>> selectAll, // type: MemoizedSelector<object, Book[]> selectTotal, // type: MemoizedSelector<object, number> } = adapter.getSelectors(selectBooksState); ```
…parent selector Closes #2751, #3172 BREAKING CHANGES: Selectors returned by the `adapter.getSelectors` signature that accepts a parent selector are strongly typed. BEFORE: ```ts const { selectIds, // type: (state: object) => string[] | number[] selectEntities, // type: (state: object) => Dictionary<Book> selectAll, // type: (state: object) => Book[] selectTotal, // type: (state: object) => number } = adapter.getSelectors(selectBooksState); ``` AFTER: ```ts const { selectIds, // type: MemoizedSelector<object, string[] | number[]> selectEntities, // type: MemoizedSelector<object, Dictionary<Book>> selectAll, // type: MemoizedSelector<object, Book[]> selectTotal, // type: MemoizedSelector<object, number> } = adapter.getSelectors(selectBooksState); ```
…parent selector Closes #2751, #3172 BREAKING CHANGES: Selectors returned by the `adapter.getSelectors` signature that accepts a parent selector are strongly typed. BEFORE: const { selectIds, // type: (state: object) => string[] | number[] selectEntities, // type: (state: object) => Dictionary<Book> selectAll, // type: (state: object) => Book[] selectTotal, // type: (state: object) => number } = adapter.getSelectors(selectBooksState); AFTER: const { selectIds, // type: MemoizedSelector<object, string[] | number[]> selectEntities, // type: MemoizedSelector<object, Dictionary<Book>> selectAll, // type: MemoizedSelector<object, Book[]> selectTotal, // type: MemoizedSelector<object, number> } = adapter.getSelectors(selectBooksState);
Minimal reproduction of the bug/regression with instructions:
https://stackblitz.com/edit/ngrx-seed-wyr8ke?file=src%2Fapp%2Freducers%2Fusers.reducer.ts
At line 22 of
app/reducers/users.reducer.ts
of the above StackBlitz, the typing of theusers
selector is(state: UsersAppState) => Users[]
. This isn't a big issue with applications, but is most notable in unit tests becauseMockStore.overrideSelector()
requires aMemoizedSelector
.Expected behavior:
The typing of the
users
selector should beMemoizedSelector<UsersAppState, User[], DefaultProjectorFn<User[]>>
when passing aselectState
selector.Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):
NgRx: 10.0.0
Angular: n/a
I would be willing to submit a PR to fix this issue
[x] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No
The text was updated successfully, but these errors were encountered: