react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Running `flow` inside a brand new project fails

Open jergason opened this issue 11 years ago • 41 comments

flowsad

Steps to reproduce:

  1. react-native init someproject && cd someproject
  2. flow init
  3. flow
  4. Cry because there are 438 errors.

I am on OS X 10.10.2, iojs 1.6.3, react-native 0.3.10, and flow 0.8.

Here is the JSON from the first few errors:

{
  "passed": false,
  "errors": [
    {
      "message": [
        {
          "descr": "NativeModules\nRequired module not found",
          "code": 0,
          "path": "/Users/jergason/code/flowbreaks/node_modules/react-native/Libraries/ActionSheetIOS/ActionSheetIOS.js",
          "line": 14,
          "endline": 14,
          "start": 29,
          "end": 52
        }
      ]
    },
    {
      "message": [
        {
          "descr": "invariant\nRequired module not found",
          "code": 0,
          "path": "/Users/jergason/code/flowbreaks/node_modules/react-native/Libraries/ActionSheetIOS/ActionSheetIOS.js",
          "line": 16,
          "endline": 16,
          "start": 17,
          "end": 36
        }
      ]
    },
    {
      "message": [
        {
          "descr": "NativeModules\nRequired module not found",
          "code": 0,
          "path": "/Users/jergason/code/flowbreaks/node_modules/react-native/Libraries/AdSupport/AdSupportIOS.js",
          "line": 14,
          "endline": 14,
          "start": 17,
          "end": 40
        }
      ]
    },
    {
      "message": [
        {
          "descr": "NativeModules\nRequired module not found",
          "code": 0,
          "path": "/Users/jergason/code/flowbreaks/node_modules/react-native/Libraries/Animation/AnimationExperimental.js",
          "line": 14,
          "endline": 14,
          "start": 27,
          "end": 50
        }
      ]
    },
    {
      "message": [
        {
          "descr": "AnimationUtils\nRequired module not found",
          "code": 0,
          "path": "/Users/jergason/code/flowbreaks/node_modules/react-native/Libraries/Animation/AnimationExperimental.js",
          "line": 15,
          "endline": 15,
          "start": 22,
          "end": 46
        }
      ]
    },
    {
      "message": [
        {
          "descr": "identifier __DEV__\nUnknown global name",
          "code": 0,
          "path": "/Users/jergason/code/flowbreaks/node_modules/react-native/Libraries/Animation/AnimationExperimental.js",
          "line": 75,
          "endline": 75,
          "start": 5,
          "end": 11
        }
      ]
    },
    {
      "message": [
        {
          "descr": "ReactPropTypes\nRequired module not found",
          "code": 0,
          "path": "/Users/jergason/code/flowbreaks/node_modules/react-native/Libraries/Animation/LayoutAnimation.js",
          "line": 14,
          "endline": 14,
          "start": 17,
          "end": 41
        }
      ]
    },
// etc
  ]
}

jergason avatar Apr 09 '15 22:04 jergason

This appears to have become an issue again on 0.17.0 of RN.

The .flowconfig requires flow at 0.19.0, which I have installed, yet it fails to resolve any react native modules:

screen shot 2015-12-23 at 11 36 25 am

This can be reproduced on a fresh project.

atticoos avatar Dec 23 '15 16:12 atticoos

+1

klvnptr avatar Dec 31 '15 11:12 klvnptr

+1

brenmcnamara avatar Jan 02 '16 20:01 brenmcnamara

I feel like I have nowhere to start with using Flow right now. Has anyone got an RN project running with Flow?

atticoos avatar Jan 03 '16 01:01 atticoos

cc @vjeux ^

brentvatne avatar Jan 03 '16 03:01 brentvatne

@gabelevi is the right person to talk to about flow :)

vjeux avatar Jan 03 '16 03:01 vjeux

@gabelevi Lemme know if you need help with testing this. I've a project already setup with flow.

satya164 avatar Jan 03 '16 04:01 satya164

+1, it looks like flow just does not work with RN from the box right now, any suggestions how to fix this? All errors i see are related to require('NativeModules')

artyomtrityak avatar Jan 16 '16 00:01 artyomtrityak

There is one solution i can propose to fix this issue - it is possible to create interface file for react-native and ExecutionEnvironment.

interfaces/react-native.js

declare module "react-native" {
  declare var exports: (callback: any) => any;
}

declare module ExecutionEnvironment {
  declare var exports: (callback: any) => any; 
}

and add to .flowconfig

[libs]
interfaces/
....
[ignore]
.*/node_modules/react-native/.*
....

[version]
0.20.1

This works for me right now, i can create pull request to update yeoman generator

artyomtrityak avatar Jan 16 '16 04:01 artyomtrityak

:+1: I would love complete support out of the box. Right now I get the following out of a new project screen shot 2016-02-28 at 12 31 07 am

Emilios1995 avatar Feb 28 '16 06:02 Emilios1995

This seems to be working for 0.21.0-rc on a fresh project. What version of RN is that @Emilios1995?

atticoos avatar Feb 28 '16 07:02 atticoos

Also on a pretty new project over here, getting 19 errors from running 'flow'. RN @ 0.29.0 flow-bin @ 0.28.0

Here's the output

cupofjoakim avatar Jul 13 '16 08:07 cupofjoakim

+1 (agree with cupofjoakim, have issue with default project seed)

phil-travelbytes avatar Jul 15 '16 03:07 phil-travelbytes

+1. I got as same issue as the one cupofjoakim reported.

luiswdy avatar Jul 20 '16 04:07 luiswdy

The 'init' project creates a .flowconfig which specifies [version] 0.27.0 - which works according to Michael Helvey in this stackoverflow post.

The actual issue for me is that flow binaries are not available in brew for back sourcing. I have flow version 0.23.1 and now 0.28, and 0.29.

brew upgrade flow --version 0.27.0 Error: No available formula with the name "0.27.0"

If these were available it would be simple to regress flow to the correct version, and then happy days :)

phil-travelbytes avatar Jul 20 '16 05:07 phil-travelbytes

@phil-travelbytes

npm install [email protected]

satya164 avatar Jul 20 '16 13:07 satya164

@satya164 thank you! Works a treat running via <PROJECT_ROOT>/node_modules/.bin/flow ...

but how do I include it in Nuclide?

phil-travelbytes avatar Jul 22 '16 03:07 phil-travelbytes

Nuclide doesn't support it yet. But support is coming - https://twitter.com/natmote/status/755871913864466433

satya164 avatar Jul 22 '16 11:07 satya164

Any recommendations if flow should be a dev dependency of a react-native project? I'm guessing yes, since the eslint version very sensitive.

justin808 avatar Jul 25 '16 02:07 justin808

+1

mt81 avatar Aug 03 '16 15:08 mt81