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 projector for selectors with props #3640

Merged
merged 1 commit into from
Nov 2, 2022

Conversation

timdeschryver
Copy link
Member

@timdeschryver timdeschryver commented Nov 2, 2022

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?

Does this PR introduce a breaking change?

[x] Yes
[ ] No

BREAKING CHANGE:

The projector method has become strict

BEFORE:

You could pass any arguments to the projector method

const selector = createSelector(
  selectString, // returning a string
  selectNumber, // returning a number
  (s, n, prefix: string) => {
    return prefix + s.repeat(n);
  }
)

// you could pass any argument
selector.projector(1, 'a', true);

AFTER:

const selector = createSelector(
  selectString, // returning a string
  selectNumber, // returning a number
  (s, n, prefix: string) => {
    return prefix + s.repeat(n);
  }
)

// this throws
selector.projector(1, 'a', true);
// this does not throw because the arguments have the correct type selector.projector(1, 'a', 'prefix');

Follow up to #3581

Other information

BREAKING CHANGE:

The projector method has become strict

BEFORE:

You could pass any arguments to the projector method

const selector = createSelector(
  selectString, // returning a string
  selectNumber, // returning a number
  (s, n, prefix: string) => {
    return prefix + s.repeat(n);
  }
)

// you could pass any argument
selector.projector(1, 'a', true);

AFTER:

const selector = createSelector(
  selectString, // returning a string
  selectNumber, // returning a number
  (s, n, prefix: string) => {
    return prefix + s.repeat(n);
  }
)

// this throws
selector.projector(1, 'a', true);
// this does not throw because the arguments have the correct type
selector.projector(1, 'a', 'prefix');
@netlify
Copy link

netlify bot commented Nov 2, 2022

Deploy Preview for ngrx-io canceled.

Name Link
🔨 Latest commit 4875fcf
🔍 Latest deploy log https://app.netlify.com/sites/ngrx-io/deploys/636282a1d114c400084215aa

@brandonroberts brandonroberts merged commit 351459f into master Nov 2, 2022
@brandonroberts brandonroberts deleted the feat/strict-selectors-with-props branch November 2, 2022 19:04
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
3 participants