Adds static typing to JavaScript to improve developer productivity and code quality.
OCaml JavaScript C Shell Ruby CSS Other
Latest commit 46fffac Jan 24, 2017 @mroch mroch committed with facebook-github-bot add reason to MaybeT
adds a reason to `MaybeT` so that it can track its own location that
includes the `?`. the `MaybeT` location is used when decomposing into `NullT`
and `VoidT` so that errors include the `?` so that we get

^^^^^^^ null. This type is incompatible with

instead of the slightly nonsensical

 ^^^^^^ null. This type is incompatible with

Reviewed By: samwgoldman

Differential Revision: D4417459

fbshipit-source-id: e1724f055068a7614521e5195833a3e440a50479
Failed to load latest commit information.
examples [flow docs] Main page, "Getting Started", & "Five Simple Examples" re… Mar 5, 2016
flow-typed ./tool test --watch Jul 22, 2016
hack [hack] Process unit tests Jan 20, 2017
js Add emoji to server status messages Jan 11, 2017
lib Buffer.from(): avoid clash between Iterable<number> and string case f… Jan 20, 2017
newtests Constant folding array literal rest elements Jan 16, 2017
npm-flow-lib `flow-lib`: JS interfaces for Flow APIs Aug 9, 2016
resources [travis] use node6 when deploying Nov 14, 2016
scripts Gracefully handle no git or hg on Windows Jul 25, 2016
src add reason to MaybeT Jan 24, 2017
tests add reason to MaybeT Jan 24, 2017
tsrc Avoid 80char lint errors in tool tests & fix flow check Jan 12, 2017
website Minor typo `it's` -> `its` Jan 23, 2017
.flowconfig Add npm-flow-lib to .flowconfig's ignore Sep 2, 2016
.gitattributes Ignore line endings in some esprima tests Oct 19, 2016
.gitignore [parser] add script to test flow against esprima3 tests Oct 18, 2016
.merlin Adds merlin file configuration Aug 23, 2015
.travis.yml stop building ocaml-4.01 on travis Dec 15, 2016
00_config.ocp Update build system and some fixes on the test-suite on Windows Dec 17, 2015 Add contributing rules Apr 24, 2015 v0.38.0 Jan 18, 2017
LICENSE Updated all copyright license headers Feb 8, 2016
Makefile Fix Makefile not to spew on missing js_of_ocaml Dec 7, 2016
PATENTS Sync changes to upstream Apr 16, 2015 Document the existence of compiled-to-JS Flow parser on npm Nov 1, 2016
README.win32 Update build system and some fixes on the test-suite on Windows Dec 17, 2015
_tags Fix parser makefile for 4.03.0 May 10, 2016
appveyor.yml Attempt to fix AppVeyor GitHub release artifact upload Nov 28, 2016
make.bat Continuous integration for Windows with AppVeyor Jun 24, 2016
ocp_build_flow.ocp.fb Fix the ocp-build build Nov 15, 2016
ocp_build_hack.ocp.fb Fix open source builds after sqlite work Nov 1, 2016
package.json Upgrade ./tool test's diff algo to support large strings Jan 6, 2017 Avoid log spew Jan 16, 2017
tool ./tool babel Sep 1, 2016

Flow Build Status Windows Build Status

Flow is a static typechecker for JavaScript. To find out more about Flow, check out

For a background on the project, please read our launch blog post.


Flow works with:

  • Mac OS X
  • Linux (64-bit)
  • Windows (64-bit)

There are binary distributions for each of these platforms and you can also build it from source on any of them as well.

Installing Flow

Flow is simple to install: all you need is the flow binary on your PATH and you're good to go.

Installing Flow Per Project

The recommended way to install Flow is via the flow-bin npm package. Adding flow-bin to your project's package.json:

  • provides a smoother upgrade experience, since the correct version of Flow is automatically used based on the revision you check out
  • installs Flow as part of your existing npm install workflow
  • lets you use different versions of Flow on different projects
npm install --save-dev flow-bin

Installing Flow Globally

Although not recommended, you can also install Flow globally (for example, perhaps you don't use npm or package.json).

The best way to install globally is via flow-bin:

npm install -g flow-bin
flow # make sure `npm bin -g` is on your path

On Mac OS X, you can install Flow via the Homebrew package manager:

brew update
brew install flow

You can also build and install Flow via the OCaml OPAM package manager. Since Flow has some non-OCaml dependencies, you need to use the depext package like so:

opam install depext
opam depext --install flowtype

If you don't have a new enough version of OCaml to compile Flow, you can also use OPAM to bootstrap a modern version. Install OPAM via the binary packages for your operating system and run:

opam init --comp=4.03.0
opam install flowtype
eval `opam config env`
flow --help

Getting started

Getting started with flow is super easy.

  • Initialize Flow by running the following command in the root of your project
flow init
  • Add the following to the top of all the files you want to typecheck
/* @flow */
  • Run and see the magic happen
flow check

More thorough documentation and many examples can be found at

Building Flow

Flow is written in OCaml (OCaml 4.01.0 or higher is required) and (on Linux) requires libelf. You can install OCaml on Mac OS X and Linux by following the instructions at

For example, on Ubuntu 14.04 and similar systems:

sudo apt-get install ocaml libelf-dev

On OS X, using the brew package manager:

brew install ocaml ocamlbuild libelf opam

Once you have these dependencies, building Flow just requires running


This produces a bin folder containing the flow binary.

Note: at this time, the OCaml dependency prevents us from adding Flow to npm. Try flow-bin if you need a npm binary wrapper.

Flow can also compile its parser to JavaScript. Read how here.

Using Flow's parser from JavaScript

While Flow is written in OCaml, its parser is available as a compiled-to-JavaScript module published to npm, named flow-parser. Most end users of Flow will not need to use this parser directly (and should install flow-bin from npm above), but JavaScript packages which make use of parsing Flow-typed JavaScript can use this to generate Flow's syntax tree with annotated types attached.

Running the tests

To run the tests, first compile flow using make. Then run bash ./ bin/flow

There is a make test target that compiles and runs tests.

To run a subset of the tests you can pass a second argument to the file.

For example: bash bin/flow class | grep -v 'SKIP'

Join the Flow community


Flow is BSD-licensed. We also provide an additional patent grant.