Skip to content

fix(store): improve types for string selectors#2174

Merged
brandonroberts merged 4 commits into
masterfrom
pr/select-typings
Oct 28, 2019
Merged

fix(store): improve types for string selectors#2174
brandonroberts merged 4 commits into
masterfrom
pr/select-typings

Conversation

@timdeschryver

Copy link
Copy Markdown
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] 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 #

The string selectors don't have the correct types:

  • Does not infer correctly, it will always(?) infer to any
books = this.store.select('books')
  • Are not type safe
books = this.store.select('books', 'notExistingState')

What is the new behavior?

The new behavior will infer correctly and will throw errors if the state property is missing.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Similar PRs:

/cc @alex-okrushko

@ngrxbot

ngrxbot commented Oct 22, 2019

Copy link
Copy Markdown
Collaborator

Preview docs changes for 89dd230 at https://previews.ngrx.io/pr2174-89dd230/

this.store
.pipe(
select(this.stateKey),
select(this.stateKey as any),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like router_store needs some typing cleanup :-/

@brandonroberts brandonroberts merged commit 46a8467 into master Oct 28, 2019
@brandonroberts brandonroberts deleted the pr/select-typings branch October 28, 2019 12:31
@timdeschryver

Copy link
Copy Markdown
Member Author

@macjohnny fyi, we decided to improve the typings

jordanpowell88 pushed a commit to jordanpowell88/platform that referenced this pull request Nov 14, 2019
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.

4 participants