Flow-for-vscode: Compile while typing

Created on 15 Aug 2016  路  7Comments  路  Source: flowtype/flow-for-vscode

In #8 you mention the possibility of having compilation while typing. This would be a great help as now I have to save file always when compiling. The other plugin for vscode-flow has this feature enabled, but other than that it's pretty useless as it make a lot of errors. Your plugin works very nice, but misses this feature. Any possibility of implementing this? Thanks for all the work!

Most helpful comment

I've decided to change tack. Instead of cobbling together a solution with the caveats above I'm going to develop a way for editors to maintain a persistent connection to Flow. This will solve a bunch of problems well, and longer-term will make it easier for us to present errors as you type without the caveats listed above. Rather than invest effort in a short-term solution I'm going to pursue this longer-term solution. Unfortunately the first steps will not allow for errors as you type, but hopefully it's available in about 3-4 months.

In the mean time, anyone who is interested is welcome to implement the short-term solution described above.

All 7 comments

See https://github.com/facebook/nuclide/issues/604 for my explanation on why this is difficult to get right with the current state of things. I've added the necessary changes to Flow. Some restructuring has to be done to take advantage of them in Nuclide and I'm not sure when I'll have time for it. But once I do someone should be able to update this plugin to take advantage of those changes.

@nmote this looks unblocked from the flow side - is it? if so, would this work by piping the current (potentially unsaved) document's text to flow check-contents an then working against the response?

if so, would this work by piping the current (potentially unsaved) document's text to flow check-contents an then working against the response?

I'm not sure how this would work if that file (module) imports other modules.

Yeah, with the right flags to check-contents you can do this now, with a couple caveats:

1) check-contents reports errors for the given file based on other files' contents on disk. so, if you have multiple unsaved files in your editor you will get inconsistent errors
2) you still need to call flow status after a save to make sure you get the errors in other files that have been introduced by the changes to the current file
3) when you get those results back from flow status you need to remember which files are currently unsaved and don't update the results for them

None of this is particularly hard but I just haven't gotten around to it yet. It might be a nice little end-of-year project though so I'll try to slot it in in the next couple weeks. Then you can just copy the code from Nuclide.

Also, if you don't care about handling the multiple-unsaved-file case gracefully, then this is really easy.

Oh, and @minedeljkovic: there's a --file argument (or similar) to check-contents that allows Flow to properly resolve other modules, since it knows where the given file lives.

Cool, thanks!

I've decided to change tack. Instead of cobbling together a solution with the caveats above I'm going to develop a way for editors to maintain a persistent connection to Flow. This will solve a bunch of problems well, and longer-term will make it easier for us to present errors as you type without the caveats listed above. Rather than invest effort in a short-term solution I'm going to pursue this longer-term solution. Unfortunately the first steps will not allow for errors as you type, but hopefully it's available in about 3-4 months.

In the mean time, anyone who is interested is welcome to implement the short-term solution described above.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rattrayalex-stripe picture rattrayalex-stripe  路  4Comments

siegebell picture siegebell  路  5Comments

jpokrzyk picture jpokrzyk  路  6Comments

ajhyndman picture ajhyndman  路  4Comments

spudly picture spudly  路  6Comments