How to get Flow type checker to detect changes in my files?

60 Views Asked by At

So Flow only works correctly the first time I run it, and then I have to restart my computer before it'll work correctly again.

Specifically, the problem I'm seeing is that we are using the Flow language to add type annotations to our JS code. Our linter script is setup to run flow type checking among other things. However, when I fix an issue in my code and then rerun the linter script, it still comes back with the exact same errors... BUT when it shows the piece of code where the error is supposed to be, it actually shows my updated code that's fixed.

So as an example, I had a file I copied into the project, that I didn't think I really needed, but maybe I would. So I copied it in just in case. Well then it came up with a bunch of linter errors, so I decided to just delete the file since I didn't really need it. So then I run "yarn lint --fix" again, but it's still complaining about that file, EVEN THOUGH THE FILE DOESN"T EXIST! Now interestingly, where the linter output is supposed to show the code for those errors it's just blank.

Or another example, let's say I had a couple of functions in my code:

100: function foo() {}
...
150: function bar() {}

And foo has a lot of errors because it was some throw away code I don't need anymore and so I just delete it. So the new code looks like:

100: function bar() {}

Well I rerun the linter and get an error like:

Error ------------------------ function foo has incorrect
something...blah blah
  src/.../file.js
  100| function bar() {}

I also tested this out on a coworker's machine and they got the same behavior that I did. So it's not something specific to my machine, although it could be specific to our project?

Note: There doesn't appear to be a tag for Flow, but I couldn't post without including at least one tag, so I used flowlang even though that's actually a different language :-( I'm assuming that anyone looking for flow would also use that tag since it's the closest.

1

There are 1 best solutions below

0
On

The first time you launch Flow it starts up a background process that is then used for subsequent type checking. Unfortunately this background process is extremely slow, and buggy to boot. In linux you can run:

killall flow

To stop the background process. Then if you rerun the flow type checker, it will actually see all your latest changes.