Flow takes very long to start up because it checks node_modules
I added Flow to my React/Redux/Webpack project and initially, it was great, I loved the type annotations. Over time, I noticed that the start up time of the project became really slow - around 120s; it used to be around 20s. Upon investigation, I realized that it was because Flow was scanning through all the JS files in node_modules. I attempted to ignore node_modules in .flowconfig by adding: [ignore] .*node_modules/.* The start up became fast again but Flow would complain Required module not found in places where I import external libraries from my code. A workaround suggested in this Github issue was to flowignore the node_modules and manually add interfaces for external libraries. This seems to work but is a hassle to maintain when new libraries are added into the project. It's frustrating to have to wait almost 2 minutes each time I start the project, are there any better ideas?
One way to avoid the Required module not found errors would be to run flow-typed install which will fetch existing libdefs for popular libraries from the flow-typed repository. It also generates stubs for the libraries that cannot be found in it. This works great for many projects but in some rare cases, the stubs for certain libraries like Immutable.js were not generated. I eventually came up with cli command flow-scripts to automatically generate the libdef stub interfaces such that I could flowignore node_modules but not get the Required module not found errors. Simply run $ flow-scripts stub in the root of the repository and the libdef stubs will be automatically generated in flow-typed directory.
type-checking function signatures with less or more arguments
what is the right location for .js.flow in flowtype?
how to declare modules that has other modules in Flowtype?
How should a disjoint union wrapper be structured for refinement to work?
how to specify a range of folders in ignore section of Flowtype .flowconfig?
Filtering out maybe types before accessing nullable property
flowtype - higher order functions - currying
Flowtype: array of possible strings cannot be empty?
Defining an object consisting of other object types in Flow
Idiomatic way to access properties of union type
how to set the status of err to avoid flowtype check warning?
How can I get inferred type data with flowtype command?
Flow bool, boolean and Boolean
how to reuse object type definition in class definition in flowtype
flow fails on union type even with if/else
Strange error message “inconsistent use of library definitions” in flowjs