Skip to content
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

feat(store): strict projectors #3581

Merged
merged 5 commits into from
Nov 2, 2022

Conversation

david-shortman
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

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

@netlify
Copy link

netlify bot commented Sep 17, 2022

Deploy Preview for ngrx-io canceled.

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

@david-shortman
Copy link
Contributor Author

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
Copy link
Contributor Author

Planning to update to remove the conditional generics this week.

@david-shortman david-shortman marked this pull request as ready for review October 22, 2022 21:15
@brandonroberts
Copy link
Member

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

@david-shortman
Copy link
Contributor Author

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.

@brandonroberts
Copy link
Member

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.

@david-shortman
Copy link
Contributor Author

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.

modules/store/src/selector.ts Outdated Show resolved Hide resolved
modules/store/src/selector.ts Outdated Show resolved Hide resolved
timdeschryver and others added 2 commits November 2, 2022 13:15
Co-authored-by: Marko Stanimirović <[email protected]>
Co-authored-by: Marko Stanimirović <[email protected]>
Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

@brandonroberts brandonroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📦

@brandonroberts brandonroberts merged commit 43198a2 into ngrx:master Nov 2, 2022
@david-shortman
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Selectors: typed projector methods
4 participants