-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Type
Object.values
and Object.entries
values when called with a d…
…ictionary (mixed otherwise) Summary: User request from Dec 2021, May 2021, Dec 2020, Apr 2020 For `Object.entries`, keys is typed exactly like it is for `Object.keys` For both, values is typed as such: - Dictionaries: the value of the dictionary - Objects & Instances: `mixed` - this avoids created non-performant union types Error diff analysis: - Previously, `Object.entries` returned `string` for the key type, rather than having the same behavior as `Object.keys`. We unsafely allow property read/writes with `string`. - Error code for suppressions has changed in some places from `incompatible-call` to `incompatible-use` - Many errors have simply moved (previously error on usage of `mixed`, now erroring on still invalid but more accurate type) After WWW diff D41527152, errors are only around ~500. Alternative 1 was to create a new utility type `$DictValues` and type the `Object.values` and `Object.entries` lib defs with this. Cons of this approach are introducing a new lib def, and the fact that `Object.entries` keys definition would differ from `Object.keys`, since `$Keys` and `Object.keys` are implemented differently. Changelog: [errors] Instead of `mixed`, type the result of `Object.values` and `Object.entries` on a dictionary to be the dictionary values, and `Object.entries` keys to behave like `Object.keys` Closes #2174, #2221, #4771, #4997, #5838 Reviewed By: jbrown215 Differential Revision: D35710131 fbshipit-source-id: 3163bc02dfc7cb70a5d6c0ba7da574a793672421
- Loading branch information
1 parent
297c286
commit b9aae51
Showing
11 changed files
with
475 additions
and
104 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
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
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
Oops, something went wrong.