platform
platform copied to clipboard
feat(entity): strengthen typing of getInitialState
PR Checklist
Please check if your PR fulfills the following requirements:
- [x] The commit message follows our guidelines: https://github.com/ngrx/platform/blob/main/CONTRIBUTING.md#commit
- [x] Tests for the changes have been added (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
PR Type
What kind of change does this PR introduce?
[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:
What is the current behavior?
Closes #4422
When initializing an EntityAdapter<T> and subsequently setting the initialState using ...adapter.getInitialState({
What is the new behavior?
This small change modifies the interface to require that the input state S extends EntityState<T>, requires that the additionalState state argument conforms to an Omit version of this S type, which removes the 'id' and 'entities' properties by way of keyof EntityState<T>, and then finally, since the argument now already extends EntityState<T>, we can now simply return S.
Does this PR introduce a breaking change?
[x] Yes
[ ] No
Other information
This reopens #4423 (with an update of the branch) - with the upcoming release this is a good timing imho.
Deploy Preview for ngrx-io canceled.
| Name | Link |
|---|---|
| Latest commit | c1892a4feb10afb45e30f31397df8f8d9349b2b9 |
| Latest deploy log | https://app.netlify.com/projects/ngrx-io/deploys/686253967c59840008e5536c |
Deploy Preview for ngrx-site-v19 ready!
| Name | Link |
|---|---|
| Latest commit | c1892a4feb10afb45e30f31397df8f8d9349b2b9 |
| Latest deploy log | https://app.netlify.com/projects/ngrx-site-v19/deploys/6862539681fcc80008c074fd |
| Deploy Preview | https://deploy-preview-4819--ngrx-site-v19.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify project configuration.
Thanks very much for closing this out @timdeschryver!
Thank you for bringing this up and opening a PR @GavynHolt!