I like using Flow since it provides amazing extension to existent JavaScript code. The type system is efficient, mostly straightforward, and error reports are user-friendly.
I want to thank anyone who's involved in development, it's a great tool.
There is only one thing that bugs be for long time already. You can find it partially reported: https://github.com/facebook/flow/issues/5619, https://github.com/facebook/flow/issues/5586, https://github.com/facebook/flow/issues/5316, https://github.com/facebook/flow/issues/5180, https://github.com/facebook/flow/issues/5495. Sometimes, for some unexpected reasons (mostly after version update), Flow just stops seeing errors (even explicitly made). Me and my colleagues tried tons of ways to work around this: manually killing server instances, looking for temp files that should be cleaned up, etc. Still, Flow can just not report errors.
This is really frustrating since you can't really rely on this tool output. I hope maintainers can prioritize this issue and not just close this ticket as duplication. I'm not familiar with OCaml so there is no even a way to debug this thing locally from my side.
Thank you again for your work and wish we can continue improving Flow.
Alexey
Can you show your .flowconfig?
My .flowconfig is:
[libs]
typings/
[options]
module.system.node.resolve_dirname=node_modules
module.system.node.resolve_dirname=src
esproposal.class_instance_fields=enable
esproposal.class_static_fields=enable
I use Node 8.6, macOS Sierra, Flow 0.63.1
You need to remove this part from your config:
[options]
module.system.node.resolve_dirname=node_modules
module.system.node.resolve_dirname=src
esproposal.class_instance_fields=enable
esproposal.class_static_fields=enable
And instead of module.system.node.resolve_dirname=src use something like
module.name_mapper='^components/\(.*\)$' -> '<PROJECT_ROOT>/src/components/\1'
for each directory in src
Could you please explain why do I need to remove that part of my config? It is what I found in Flow docs and used based on what I鈥檓 able to do in JS with CRA setup.
You don't have to declare stuff like these because it works by default:
module.system.node.resolve_dirname=node_modules
esproposal.class_instance_fields=enable
esproposal.class_static_fields=enable
You must not use
module.system.node.resolve_dirname=src
because it works not as you think it works. It marks src as node_modules-like folder. Files in node_modules flow treats in a special way so it causes problems. Use module.name_mapper instead.
@alexeyraspopov We have same kind of problem in my team too... It started to behave like that around 0.57.0-0.58.0 .
After saving some files, it seems to "unlock" a partial stack of error. So while coding, flow seems to work in an indeterminate manner which is very frustrating.
@jpolo It was introduced here https://github.com/facebook/flow/issues/869#issuecomment-336513601
@apsavin Excellent catch!
If getting rid of resolve_dirs requires non-trivial amount of work, a temporary workaround is to add an entry point from outside src/ to the entry point of your app.
In the example bellow <PROJECT_ROOT>/src/index.js is the entry point of the app and we add a file <PROJECT_ROOT>/__flow-tests__/flow-index.js which references it:
/* @flow */
/* This is necessary to mitigate https://github.com/facebook/flow/issues/5647 */
import '../src';
It marks src as node_modules-like folder. Files in node_modules flow treats in a special way so it causes problems. Use module.name_mapper instead.
@apsavin, is there any explanation in docs regarding this behavior?
@alexeyraspopov I'm not sure there is.
I guess I saw some explanation of "lazy" mode when it comes to reading node_modules folder. I though, maybe it would be better to link this explanation to config page, so users like me won't use that options for things it wasn't created for.
And instead of module.system.node.resolve_dirname=src use something like
module.name_mapper='^components/(.*)$' -> '
/src/components/\1' for each directory in src
This is seriously the right "solution"? Instead of 1 option for every module resolve root configured once only at starting a project, now it requires us to manually write all modules for all resolve module roots? So whenever I'll add a component (which is inside its own module), I must also manually add a line to flowconfig? This is very cumbersome and actually might be a reason to not use Flow...
Most helpful comment
This is seriously the right "solution"? Instead of 1 option for every module resolve root configured once only at starting a project, now it requires us to manually write all modules for all resolve module roots? So whenever I'll add a component (which is inside its own module), I must also manually add a line to flowconfig? This is very cumbersome and actually might be a reason to not use Flow...