MCPcopy Index your code
hub / github.com/facebook/flow

github.com/facebook/flow @v0.321.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.321.0 ↗ · + Follow
40,762 symbols 132,617 edges 8,995 files 2,876 documented · 7%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Flow

CircleCI Follow @flowtype MIT License GitHub contributors GitHub top language Join Discord Chat

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

Contents

Requirements

Flow works with:

  • macOS (x86_64)
  • Linux (x86_64 and arm64)
  • Windows (x86_64, Windows 10 recommended)

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

Using Flow

Check out the installation instructions, and then the usage docs.

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, but JavaScript packages which make use of parsing Flow-typed JavaScript can use this to generate Flow's syntax tree with annotated types attached.

Building Flow from source

Flow is written in OCaml (OCaml 5.2.0 is required).

  1. Install system dependencies:

    • Mac: brew install opam
    • Debian: sudo apt-get install opam
    • Other Linux: see opam docs
    • Windows: cygwin and a number of dependencies like make, gcc and g++ are required.

    One way to install everything is to install Chocolatey and then run .\scripts\windows\install_deps.ps1 and .\scripts\windows\install_opam.ps1. Otherwise, see the "Manual Installation" section of OCaml for Windows docs and install all of the packages listed in our install_deps.ps1.

    The remainder of these instructions should be run inside the Cygwin shell: C:\tools\cygwin\Cygwin. Then cd /cygdrive/c/Users/you/path/to/checkout.

  2. Validate the opam version is 2.x.x:

    sh opam --version

    The following instructions expect 2.x.x. Should your package manager have installed a 1.x.x version, please refer to the opam docs to install a newer version manually.

  3. Initialize opam:

    ```sh

    on Mac and Linux:

    opam init

    on Windows:

    scripts/windows/init_opam.sh ```

  4. Install Flow's OCaml dependencies:

    ```sh

    from within this git checkout

    make deps ```

    note: If you find that you get an error looking for ocaml-base-compiler version, your local dependency repo may be out of date and you need to run opam update + opam upgrade

  5. Build the flow binary:

    sh eval $(opam env) make

    This produces the bin/flow binary.

  6. Build flow.js (optional):

    sh make js

    This produces bin/flow.js from the Rust port. Install Emscripten and a Rust toolchain with the wasm32-unknown-emscripten target and rust-src component first.

    To build a faster, larger local development version instead, run:

    sh make js FLOW_JS_IMPL=rust-wasm FLOW_DOT_JS_WASM_PROFILE=dev

    The Flow parser can also be compiled to JavaScript. Read how here.

Running the tests

See tests/README.md for detailed testing documentation.

Join the Flow community

License

Flow is MIT-licensed (LICENSE). The website and documentation are licensed under the Creative Commons Attribution 4.0 license (website/LICENSE-DOCUMENTATION).

Extension points exported contracts — how you extend this code

TypeVisitor (Interface)
We walk types in a lot of places for all kinds of things, but often most of the code is boilerplate. The following visit [13 …
rust_port/crates/flow_typing_visitors/src/type_visitor.rs
ClassAccessorDecoratorTarget (Interface)
* Describes the target provided to class `accessor` field decorators. * @template This The `this` type to which the tar [5 …
tslib/lib.decorators.d.ts
MergedMethods (Interface)
(no doc) [23 implementers]
tests/interface_merging_libdefs/flow-typed/declares.js
IFace (Interface)
(no doc) [17 implementers]
tests/partial/test.js
SuperWithMethod (Interface)
(no doc) [111 implementers]
tests/interface/indexer.js
NotConstructable (Interface)
(no doc) [50 implementers]
tests/new_on_interface/new_on_interface.js
CArrays (Interface)
(no doc) [50 implementers]
tests/lib_interfaces/declarations/underscore.js
NotConstructable (Interface)
(no doc) [50 implementers]
tests/constructor_type/constructor_type.js

Core symbols most depended-on inside this repo

clone
called by 6274
tests/this_type_ts/module.ts
map
called by 3545
tslib/lib.es5.d.ts
as_ref
called by 3089
rust_port/crates/flow_utils_concurrency/src/with_hash.rs
push
called by 2758
tslib/lib.es5.d.ts
to_string
called by 2244
rust_port/crates/flow_typing_type/src/type_.rs
collect
called by 2046
rust_port/crates/flow_typing_type/src/type_.rs
deref
called by 1788
tslib/lib.es2021.weakref.d.ts
get
called by 1084
tslib/lib.es2015.collection.d.ts

Shape

Function 19,563
Method 9,301
Class 9,161
Interface 1,624
Enum 1,113

Languages

Rust50%
TypeScript50%

Modules by API surface

packages/prettier-plugin-flow-parser/index.mjs1,463 symbols
rust_port/crates/flow_parser/src/ast_visitor.rs1,337 symbols
rust_port/crates/flow_typing_type/src/type_.rs536 symbols
tslib/lib.es5.d.ts506 symbols
tests/uninitialized_instance_property/test.js472 symbols
rust_port/crates/flow_parser_utils/src/flow_ast_differ_tests.rs370 symbols
rust_port/crates/flow_env_builder_resolver/src/name_resolver.rs368 symbols
rust_port/crates/flow_env_builder_resolver/src/env_builder_refinement_test.rs352 symbols
website/flow-typed/environment/dom.js344 symbols
website/flow-typed/environment/bom.js334 symbols
rust_port/crates/flow_parser/src/polymorphic_ast_mapper.rs329 symbols
packages/flow-dev-tools/flow-typed/environments/bom.js320 symbols

For agents

$ claude mcp add flow \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact