flow README

The project's README from github.com/facebook/flow. As one markdown file: README.md.

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:

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

Flow's 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 Rust. GitHub CI builds Flow from the rust_port workspace with nightly Rust.

  1. Install system dependencies:

    • Install Rust via rustup.

    • Install the nightly Rust toolchain:

      rustup toolchain install nightly
      
  2. Build the Rust workspace:

    cd rust_port
    cargo +nightly build
    
  3. Run the Rust tests:

    cargo +nightly test
    
  4. Build an optimized flow binary:

    cargo +nightly build --release --bin flow_cli
    
  5. Build flow.js (optional):

    The flow.js build also uses the Rust port. Install Emscripten, Node, Yarn, and a Rust nightly toolchain with the wasm32-unknown-emscripten target and rust-src component first. GitHub CI uses Emscripten 3.1.44 and nightly Rust for this build.

    rustup toolchain install nightly-2026-04-14 --target wasm32-unknown-emscripten --component rust-src
    RUSTUP_TOOLCHAIN=nightly-2026-04-14 make js FLOW_JS_IMPL=rust-wasm
    

    This produces bin/flow.js.

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

    RUSTUP_TOOLCHAIN=nightly-2026-04-14 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).

flow (facebook/flow)

Searching Database…

22.3K ·GitHub
这是什么?Flow 是一个 JavaScript 静态类型检查工具:它为你的代码加上静态类型,以便尽早在编写阶段发现错误、提升代码质量。项目始于 2014 年,用 Rust 编写。
它是我要导入的库,还是命令行工具?是命令行工具:你对代码库运行 flow 命令,它会报告类型错误。不需要导入任何东西——你只需在 JavaScript 里添加类型注解。
我怎么把它跑起来?按照 flow.org 上的安装说明操作,然后参考使用文档。所有支持的平台都有预编译的二进制文件,所以一般无需自己编译。
运行它需要装 Node 或其他运行时环境吗?只需要那个二进制文件本身——不需要 Node、Python 或其他运行时。只有在你从源码构建可选的 flow.js 时,才会用到 Node、Yarn 和 Emscripten。
哪些系统能运行它——Intel 芯片的 Mac 可以往吗?支持 macOS(arm64)、Linux(x86_64 或 arm64)和 Windows(x86_64,建议 Windows 10)。Intel 芯片的 Mac 不在支持列表里,这种情况下你得自己从源码构建。
我可以在商业项目里用它吗?可以:Flow 采用 MIT 许可证,商业使用没有问题。官网和文档则单独采用 Creative Commons Attribution 4.0 许可。
我自己的工具能解析带 Flow 类型标注的代码吗?可以——flow-parser 是一个编译成 JavaScript 的 npm 模块,能生成 Flow 的语法树,并附带类型标注。它是给写开发工具的人用的;大多数最终用户不会直接接触它。
检查器本身有 JavaScript 版本吗?有:可选的 flow.js 构建会用 Emscripten 把 Rust 代码编译成 bin/flow.js(需要 Node、Yarn、Emscripten,以及带 wasm32-unknown-emscripten 目标的 nightly 版 Rust)。文档里还介绍了一种更快但体积更大的本地开发版构建方式。
Flow 现在还在活跃维护吗?看起来还在:仓库创建于 2014 年 10 月,大约有 22k 星标,没有被归档,CI 上仍在运行构建和测试流程。Discord、IRC 和 Stack Overflow 上也有活跃的社区。
Creator
facebook
Size
184.8 MB
Stars
22.3K
Age
11y
Commits · 90 Days