-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(entity): add undefined to Dictionary's index signature (#1719)
BREAKING CHANGE: Dictionary could be producing undefined but previous typings were not explicit about it.
- Loading branch information
1 parent
0abc948
commit d472757
Showing
3 changed files
with
12 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d472757
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Alex, do you have any more info on what exactly are/were the places where the EntityStore is/was expected to be storing values that are undefined?
d472757
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mtaran-google generally accessing entity by index could return undefined.
d472757
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right that querying the entity dictionary by index can potentially return undefined, but I don't think that's sufficient reason to add
| undefined
in these types. To me, this seems to mirror the issue at the core of this TypeScript FR, and this comment really sums up the problems that this typing results in. TL;DR: It adds extra warnings both where they're useful and where they're not, which results in the user learning to ignore these kinds of type errors, leading to them not really being any more helpful than if they were absent.d472757
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dictionary is returned when you do
selectEntities
- which are meant to be accessed by index. They should have checks forundefined
.If you need the entire collection as an Array you could use
selectAll
and then theT[]
would be returned - without undefined types.