Flow: check single file?

Created on 25 Feb 2016  路  15Comments  路  Source: facebook/flow

It's great that the flow command checks all the files in a project, but is there any way to run it on a specific file? While learning I have many files in the current directory that each may have some type error. I want to run Flow on them one at a time to focus on learning a particular aspect.

Most helpful comment

for people landing on this page from google (like me)

flow check-contents path/to/file.js < path/to/file.js

will correctly set the current path and avoid all these import errors.

All 15 comments

@mvolkmann Well, you could do something like flow check-contents < path/to/file.js, but you might run into trouble with that, particularly if your file depends on other local modules, .flowconfig, etc. Hope it helps.

Yes, that is exactly what I need. Thanks!

I've tried this

flow check-contents < src/actions/appActions.js 

And it returned this error

import * as types from './actionTypes';
                            ^^^^^^^^^^^^^^^ ./actionTypes. Required module not found

Can we check a single file and also include files that this file reference?

is there something for this?

I'm working on this. Have a working POC. Should I go forward with this?

@iddan please do

It's written it in Node.js should I create a PR to the source in OCaml or is a POC reference is enough?

I think you should create a POC and start a RFC about it

@iddan did your POC worked well?

@calebmer can flow focus-check reports only errors of selected files?

My POC worked well. For some reason it is much more performant than flow focus-check

You should publish it to npm

It is just a sketch. What really should be is that the idea will be integrated to Flow and affect the editor extensions making Flow usable to the public

for people landing on this page from google (like me)

flow check-contents path/to/file.js < path/to/file.js

will correctly set the current path and avoid all these import errors.

@samwgoldman can you give us some hints of why what @malectro wrote works?

The thing is why we should duplicate our selfs and wirte same path two times? I knwo what < is, i'm linux guy for years. But.. It is also not cool for executing through things like Nodejs's spawn? Or.. how such things can be done programmatically? Without things such as cash and shelljs?

edit: Actually, i'm seeing that focus-check works well for what i described? What are the real differences between both commands? Except that one can handle from stdin.

Was this page helpful?
0 / 5 - 0 ratings