Course contentsShow
← TypeScript
Lesson 23 of 1,7961. Why TypeScriptFree lesson

Flow: Facebook's Type Checker

Understand Flow's approach to gradual typing and how it differs from TypeScript's design philosophy.

Flow: Facebook's Type Checker

You'll learn: How Flow's gradual typing philosophy differs from TypeScript's approach to type checking.

What Is Flow?

Flow is Facebook's open-source static type checker for JavaScript, created around the same time as TypeScript (2014). While both tools aim to add static typing to JavaScript, they took different philosophical paths.

Flow's Gradual Typing Approach

Flow embraced opt-in typing more aggressively than TypeScript. Its philosophy: you can add type annotations gradually, file by file, without any configuration. Flow assumes JavaScript files are untyped unless you explicitly add a // @flow comment at the top. This "strict opt-in" model means:

  • Unchecked by default: Files without the Flow comment are ignored entirely
  • Sound typing focus: Flow prioritizes catching all type errors (even if it means rejecting valid code)
  • Minimal compilation: Flow is primarily a checker, not a full compiler

TypeScript's Different Philosophy

TypeScript, by contrast, assumes everything is opted-in once configured. It's designed as both a type checker and a compiler that transforms modern JavaScript. TypeScript prioritizes:

  • Practical soundness: It accepts some technically "unsafe" patterns if they're common in JavaScript
  • Gradual migration: You can enable strict checking incrementally via compiler options
  • Ecosystem compatibility: Built-in support for JavaScript libraries through DefinitelyTyped

The Analogy

Think of Flow as a strict grammar teacher who only grades essays you explicitly hand in—ignored papers aren't even looked at. TypeScript is like a teaching assistant who reviews everything in your folder but lets you choose how picky the feedback should be.

Key Takeaway: Flow uses strict opt-in per file and prioritizes type soundness, while TypeScript opts in entire projects and balances strictness with JavaScript ecosystem compatibility.