platform icon indicating copy to clipboard operation
platform copied to clipboard

feat(store): strict projectors

Open david-shortman opened this issue 3 years ago • 2 comments
trafficstars

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] The commit message follows our guidelines: https://github.com/ngrx/platform/blob/master/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 #3571

What is the new behavior?

The projector is strict by default, but can be bypassed with an any generic parameter.

Does this PR introduce a breaking change?

[x] Yes
[ ] No

A migration will be included to include <any> for every existing projector.

Other information

david-shortman avatar Sep 17 '22 21:09 david-shortman

Deploy Preview for ngrx-io canceled.

Name Link
Latest commit 57276e6c1c4b093a68cdc7653df91df5121ea91f
Latest deploy log https://app.netlify.com/sites/ngrx-io/deploys/63625f66859866000875fc3b

netlify[bot] avatar Sep 17 '22 21:09 netlify[bot]

Not sure how to approach the migration (#3572).

Since the projector is found on arbitrary objects, then without compiling the code and inspecting type information, you could only naively update any call of a function named projector referenced as a property from an object.

david-shortman avatar Sep 17 '22 22:09 david-shortman

Planning to update to remove the conditional generics this week.

david-shortman avatar Oct 17 '22 12:10 david-shortman

What's the experience for someone upgrading from non-strict projectors? Are all their existing selectors going to produce type errors?

brandonroberts avatar Oct 22 '22 23:10 brandonroberts

What's the experience for someone upgrading from non-strict projectors? Are all their existing selectors going to produce type errors?

Anywhere a projector is called, it will be required to be called with the correct arguments. Projectors called with incorrect arguments will produce errors.

david-shortman avatar Oct 23 '22 00:10 david-shortman

Ok, we definitely need to provide instructions on how to work around this for existing users in the migration guide, as I'm sure there will be some breakages for existing apps.

brandonroberts avatar Oct 23 '22 00:10 brandonroberts

Ok, we definitely need to provide instructions on how to work around this for existing users in the migration guide, as I'm sure there will be some breakages for existing apps.

I'll look to add to this PR.

david-shortman avatar Oct 23 '22 21:10 david-shortman

LGTM 🎉

We should also provide the same changes to MemoizedSelectorWithProps in a follow-up PR.

I assumed, since they're deprecated, they shouldn't receive updates.

david-shortman avatar Nov 02 '22 13:11 david-shortman