question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong usage of lodash.uniq in local-cli/link/link.js (should be uniqBy?) causes flow errors

See original GitHub issue

Is this a bug report?

Yes

Have you read the Bugs section of the Contributing to React Native Guide?

Yes

Environment

  1. react-native -v: 0.46.1
  2. node -v: v8.1.3
  3. npm -v: 5.1.0
  4. yarn --version: 0.27.5
  5. react-native-cli: 2.0.1

Then, specify:

  1. Target Platform (e.g. iOS, Android): both
  2. Development Operating System (e.g. macOS Sierra, Windows 10): macOS Sierra
  3. Build tools (Xcode or Android Studio version, iOS or Android SDK version, if relevant): not relevant

Steps to Reproduce

  1. add lodash and flow-typed to a new app
  2. install flow types via flow-typed install
  3. 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:

  1. react-native init ReactNativeLodashFlowWarning
  2. cd ReactNativeLodashFlowWarning
  3. yarn add --dev flow-bin@^0.47.0 flow-typed
  4. yarn add lodash
  5. yarn run flow-typed install

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
strayercommented, Jul 20, 2017

The easiest way to suppress this error seems to be this:

[ignore]
.*/node_modules/react-native/local-cli/link/link.js

[options]
module.name_mapper='^./link/link$' -> 'emptyObject'
1reaction
jkimbocommented, Oct 11, 2017

In case anyone comes across this issue again - this is fixed by https://github.com/facebook/react-native/commit/df8d0d1db9203cc87ad3682e6138b2a9ed714365

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found