-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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(entity): add undefined to Dictionary's index signature #1719
Conversation
Preview docs changes for 8c1badb at https://previews.ngrx.io/pr1719-8c1badb/ |
Co-Authored-By: alex-okrushko <[email protected]>
Co-Authored-By: alex-okrushko <[email protected]>
Preview docs changes for 5666a94 at https://previews.ngrx.io/pr1719-5666a94/ |
Preview docs changes for 8ea9a63 at https://previews.ngrx.io/pr1719-8ea9a63/ |
What message should be displayed in the breaking change? |
message in the announcement or message in the error? Dictionary could be producing |
I know I'm a bit late to the party here, but I just wanted to chime in and say that this change makes it harder to create selectors that does something more than just picking a specific index out of the dictionary. As pointed out in the Typescript-issue mentioned in the PR description (microsoft/TypeScript#13778), Typescript isn't smart enough to remove This means that Seems like we have to choose between two evils at the time being.. |
@larrifax That's correct. In cases like that I either add Also, if you need all values then |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Index signatures always return value and never return
undefined
🤯microsoft/TypeScript#13778
Typescript is telling me that I don't need to check because it's of type
number
. In reality it's actuallynumber | undefined
, and I should check for theundefined
.Suggestion in the bug from TS team is to add "
| undefined
at their definition sites".What is the current behavior?
This became particular painful when
MemoizedSelector<State, Result>
started to validate the return type of the selector to make sure it's actuallyResult
.Closes #
What is the new behavior?
If one relied on
Dictionary<Entity>
to not returnundefined
they would have to adjust the code.Does this PR introduce a breaking change?
Yes, it is. See 👆
Other information