LinuxCommandLibrary

flow

Type checker for JavaScript programs

TLDR

Run a flow check

$ flow
copy

Check which files are being checked by flow
$ flow ls
copy

Run a type coverage check on all files in a directory
$ flow batch-coverage --show-all --strip-root [path/to/directory]
copy

Display line-by-line type coverage stats
$ flow coverage --color [path/to/file.jsx]
copy

SYNOPSIS

flow [global options...] command [command options] [arguments]

PARAMETERS

--all
    Typecheck all files in project

--color={always|never|auto}
    Control colored output

--from=
    Connect to existing Flow server

--help
    Show general help

--help=
    Show help for specific command

--no-flowlib
    Do not load bundled Flow library definitions

--pretty
    Pretty-print JSON output

--respect-pragma
    Honor // flow-disable-* comments

--retries=
    Maximum server retries (default 2)

--strip-root
    Omit root filename in error messages

--timeout=
    Request timeout in milliseconds (default 10000)

--verbose
    Enable verbose logging

--version
    Print Flow version

DESCRIPTION

Flow is an open-source static type checker for JavaScript created by Facebook (now Meta). It enables developers to catch type-related errors during development without altering runtime behavior, providing sound static analysis for untyped JS code.

The flow command-line tool manages the Flow server, performs type checking, generates configurations, and offers utilities like autocomplete and coverage reports. It uses a persistent server for efficient incremental checking, analyzing entire projects or focused files.

Typical workflow: Run flow init to create a .flowconfig file specifying lib paths and options. Use flow check (--all for whole project) to verify types. Integrate with editors via LSP or autocomplete. Supports gradual typing with @flow pragma.

Flow improves code reliability, refactoring safety, and documentation via inferred types. Though less popular post-TypeScript rise, it remains used in legacy projects and where static analysis is preferred over full typing.

CAVEATS

Not a core Linux utility; requires Node.js and installation via npm install -g flow-bin or distro packages (e.g., apt install flow). Server-based; manage with flow start/stop. Deprecated in favor of TypeScript.

KEY COMMANDS

flow init: Initialize project.
flow check: Typecheck files.
flow start: Start daemon server.
flow autocomplete: Editor integration.

INSTALLATION

Global: npm install -g flow-bin.
Project: npm install --save-dev flow-bin, then npx flow.
Linux packages: Available in NodeSource or AUR.

HISTORY

Released by Facebook in May 2014 as open-source under MIT license. Gained popularity for static checking in JS ecosystems. Maintained until 2021; now in maintenance mode with latest v0.238.3 (2024). Widely used in React projects early on.

SEE ALSO

node(1), npm(1), npx(1)

Copied to clipboard