Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prevent FlowType to check error in node_modules

I have tried searching for the solution or work around to solve this but no success. Here are some steps to describe my flow installation and eventually the issue I am facing.

Step 1: I have created a new react native project using react-native init TestProject.

I wanted to configure flow for my project, but there was no .flowconfig file. As we know that the flow version is needed to be specified for installing flow locally for the project, using the following script: yarn add --dev [email protected] babel-preset-flow.

Step 2: Even though I do not have .flowconfig file and hence no information of which specific version of flow to install, I try to install flow for my project using this:

yarn add --dev flow-bin babel-preset-flow.This has installed the latest flow 0.79.1.

Step 3: To generate .flowconfig file, following script is used: ./node_modules/.bin/flow init. This created the .flowconfig file in project directory with some default entries as follows:

image

Step 4: I restarted the VSCode to start flow server:enter image description here

As the flow server was running, here I found out the there are 98 problems with the react-native library:image

Step 5 : I added ./node_modules/. under [ignore] in .flowconfig file and restarted VSCode again.image

Step 6 : Now the error caught by flow is, it cannot find the module react-native:image

Here is the project's package.json: image Here is the React Native Environment Info: image

Please suggest if anyone has solved this issue. Thanks in advance.

like image 340
Raj Avatar asked Sep 04 '18 10:09

Raj


1 Answers

You can use the [untyped]* section in your .flowconfig to tell Flow to treat the files as untyped but still recognise that they exist or even better use the new [declarations] option to just use the types even when there are errors in the library itself. This will prevent the import problem. In your case you might want to ignore only very specific dependencies because it is generally useful to get the types from libraries that are inside of your node modules.

* Introduced in Flow v0.61.0

like image 149
Herku Avatar answered Oct 19 '22 08:10

Herku