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): add an overload to createFeatureSelector to provide better type checking #1171

Merged

Conversation

timdeschryver
Copy link
Member

Closes #1136

@coveralls
Copy link

coveralls commented Jul 4, 2018

Coverage Status

Coverage remained the same at 88.161% when pulling e602913 on tdeschryver:pr/create-feature-selector-typing into e7de882 on ngrx:master.

@@ -104,6 +104,24 @@ export const selectFeatureCount = createSelector(
);
```

There is also an overload on the `createFeatureSelector` method, which allows a better typechecking.
Copy link
Member

Choose a reason for hiding this comment

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

Instead of adding this as an additional section, let's just make this the default in the example above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea I wasn't sure about this, but you just confirmed my thinking.
Should I also update the example app?

Copy link
Member

Choose a reason for hiding this comment

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

Yes


Where `AppState` is the type from the top level feature state and `FeatureState` is the type from the feature slice to select.
Meaning that the following would not compile because `foo` is not a feature slice of `AppState`.

Copy link
Member

Choose a reason for hiding this comment

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

Keep the section starting with Meaning as a note.

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.

Minor nit. Everything else LGTM

export const selectFeatureCount = createSelector(
selectFeature,
(state: FeatureState) => state.counter
);
```

Meaning that the following would not compile because `foo` is not a feature slice of `AppState`.

Copy link
Member

Choose a reason for hiding this comment

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

Change to The following selector below would not ...

Copy link
Member Author

Choose a reason for hiding this comment

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

No problem! Thanks for the reviews!

@brandonroberts brandonroberts merged commit 03db76f into ngrx:master Jul 5, 2018
@timdeschryver timdeschryver deleted the pr/create-feature-selector-typing branch July 5, 2018 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants