A static type checker and typed dialect of JavaScript
open sourceMITself-hostablefree
Flow is a static type checker for JavaScript from Meta, which calls it a typed dialect of JavaScript and uses it in production across millions of files of JavaScript and React. Its syntax now looks like TypeScript (keyof, readonly properties, unknown, indexed access, conditional and mapped types, type guards), plus first-class React components with component and renders types, and an exhaustively checked match expression. Object types are exact by default and it keeps method receivers safe, catching some errors TypeScript lets through. Types are stripped at build time with Babel, SWC or flow-remove-types, and the flow lsp command serves diagnostics, autocomplete, go-to-definition and hover types to any editor with an LSP client. Written in Rust, it ships binaries for macOS (arm64), Linux and Windows, and is MIT-licensed.
Problems it solves
- add static types to an existing JavaScript codebase without converting it to TypeScript
- catch type errors in a large React codebase before runtime
- type React components so only components that render a certain child can be passed as a prop
- check that a switch over a union handles every case
- stop extra properties slipping into objects through variables
- get type-aware autocomplete and go-to-definition for JavaScript in my editor
- strip type annotations from JavaScript at build time with Babel
Features
- TypeScript-like syntax: keyof, readonly props, unknown, indexed access types, extends bounds, conditional types, mapped types and type guards
- component and renders syntax for React
- match expressions and statements with exhaustive checking and structural patterns
- exact object types by default
- preserves method receiver constraints to reject unsafe calls
- LSP server (flow lsp) for diagnostics, autocomplete, go-to-definition, hover types and code actions
- compile types away with Babel, SWC or flow-remove-types
- Prettier and ESLint support
- Try Flow in the browser
- binaries for macOS (arm64), Linux (x86_64 and arm64) and Windows (x86_64)
Limitations
- Needs a compile step: Flow types must be stripped with Babel, SWC or flow-remove-types before the code runs12
- No Intel Mac binaries: macOS builds are arm64 only12
Capabilities
| Has a command line tool | plan not known |
|---|
Alternatives
The same job
These do what Flow does.
- TypeScript JavaScript with static types, compiled to plain JavaScript
- Be Focused Pomodoro focus timer and task list for iPhone, iPad, Mac and Apple Watch
- Sorbet A fast, powerful type checker designed for Ruby
- mypy Optional static typing for Python
- Pyright Static type checker for Python
- ty An extremely fast Python type checker and language server, written in Rust
