react native and flow error messages

前端 未结 2 1025
庸人自扰
庸人自扰 2021-02-19 19:09

Hi I was trying to do some hello world with React Native. I created project \'react-native init\' change the flow version in \'.flowconfig\'.

Ran flow and it gave me 153

相关标签:
2条回答
  • 2021-02-19 19:42

    I ran into very same problem. You need to do two steps:

    1. Compare your .flowconfig with this file and add the lines that you're missing:

    [ignore]
    ; We fork some components by platform
    .*/*[.]android.js
    
    ; Ignore "BUCK" generated dirs
    <PROJECT_ROOT>/\.buckd/
    
    ; Ignore unexpected extra "@providesModule"
    .*/node_modules/.*/node_modules/fbjs/.*
    
    ; Ignore duplicate module providers
    ; For RN Apps installed via npm, "Libraries" folder is inside
    ; "node_modules/react-native" but in the source repo it is in the root
    .*/Libraries/react-native/React.js
    .*/Libraries/react-native/ReactNative.js
    
    <PROJECT_ROOT>/node_modules/.*
    <PROJECT_ROOT>/libdefs.js
    .*/__tests__/.*
    
    [include]
    
    [libs]
    node_modules/react-native/Libraries/react-native/react-native-interface.js
    node_modules/react-native/flow
    ./libdefs.js
    

    2. create libdefs.js into root folder. It should look something like this:

    declare module 'react-native' { declare var exports: any; }
    declare module 'jest' { declare var exports: any; }
    

    Plus, declare all the modules flow throws errors about (e.g. 'mobx' -- I know this can be a bit frustrating, but it has to be done)

    0 讨论(0)
  • 2021-02-19 19:43

    Found this issue which recommended updating the flowconfig to use the latest version from create-react-native-app. Seems to have worked for me.

    0 讨论(0)
提交回复
热议问题