By default, the Flow server will typecheck all your code. This way it can answer questions like “are there any Flow errors anywhere in my code”. This is very useful for tooling, like a continuous integration hook which prevents code changes which introduce Flow errors.
However, sometimes a Flow user might not care about all the code. If they are editing a file foo.js
, they might only want Flow to typecheck the subset of the repository needed to answer questions about foo.js
. Since Flow would only check a smaller number of files, this would be faster. This is the motivation behind Flow’s lazy modes.
Lazy mode tries to classify your code into four categories.
Lazy mode will still find all the JavaScript files and parse them. But it won’t typecheck the unchecked files.
There are two ways which Flow can use to tell which files the user cares about.
flow ide
(and in the future flow lsp
). Flow treats any file which has ever been opened since the Flow server started as focused.To start a Flow server in IDE lazy mode, you run
flow server --lazy-mode ide
The IDE needs to integrate with flow ide
(or in the future flow lsp
) to tell Flow which files are open.
To start a Flow server in IDE lazy mode, you run
flow server --lazy-mode fs
You can force Flow to treat one or more files as focused from the CLI.
flow force-recheck --focus ./path/to/A.js /path/to/B.js
© 2013–present Facebook Inc.
Licensed under the MIT License.
https://flow.org/en/docs/lang/lazy-modes