Wrong usage of lodash.uniq in local-cli/link/link.js (should be uniqBy?) causes flow errors
See original GitHub issueIs this a bug report?
Yes
Have you read the Bugs section of the Contributing to React Native Guide?
Yes
Environment
react-native -v
: 0.46.1node -v
: v8.1.3npm -v
: 5.1.0yarn --version
: 0.27.5react-native-cli
: 2.0.1
Then, specify:
- Target Platform (e.g. iOS, Android): both
- Development Operating System (e.g. macOS Sierra, Windows 10): macOS Sierra
- Build tools (Xcode or Android Studio version, iOS or Android SDK version, if relevant): not relevant
Steps to Reproduce
- add lodash and flow-typed to a new app
- install flow types via flow-typed install
- run flow on unmodified react-native app
Expected Behavior
No Flow errors should occur, uniq (or uniqBy) function should be properly used.
Actual Behavior
Flow validation will fail because of incorrect usage of uniq function:
yarn run v0.27.5
$ "/Users/strayer/tmp/ReactNativeLodashFlowWarning/node_modules/.bin/flow"
Launching Flow server for /Users/strayer/tmp/ReactNativeLodashFlowWarning
Spawned flow server (pid=23674)
Logs will go to /private/tmp/flow/zSUserszSstrayerzStmpzSReactNativeLodashFlowWarning.log
node_modules/react-native/local-cli/link/link.js:38
38: const dedupeAssets = (assets) => uniq(assets, asset => path.basename(asset));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused function argument
139: uniq<T>(array: ?Array<T>): Array<T>;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type expects no more than 1 argument. See lib: flow-typed/npm/lodash_v4.x.x.js:139
Found 1 error
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Reproducible Demo
Steps to create reproducible demo:
- react-native init ReactNativeLodashFlowWarning
- cd ReactNativeLodashFlowWarning
- yarn add --dev flow-bin@^0.47.0 flow-typed
- yarn add lodash
- yarn run flow-typed install
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:5 (2 by maintainers)
Top Results From Across the Web
switching to lodash/fp from lodash causes typescript errors
In this code we are very explicitly doing work to the users array. ... The type signature for lodash and lodash/fp is different....
Read more >[@types/lodash] `_.uniqBy` - An argument for 'iteratee' was ...
I tried using the @types/xxxx package and had problems. I tried using the latest stable version of tsc.
Read more >Lodash _.uniq() Method
The _.uniq method is used to create an array of unique values in order, from all given arrays using SameValueZero for equality comparisons....
Read more >Array.prototype.uniqBy - Ideas - TC39 - Discourse
Array.prototype.uniqBy-Proposal Intro to Problem It would be useful to have the ability to get all unique objects according to some provided ...
Read more >Lodash Documentation
Creates an array of unique values that are included in all of the provided ... Note: This method is used instead of Array#slice...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The easiest way to suppress this error seems to be this:
In case anyone comes across this issue again - this is fixed by https://github.com/facebook/react-native/commit/df8d0d1db9203cc87ad3682e6138b2a9ed714365