Flow is a static type checker for JavaScript
π₯
Static type checking is the process of verifying the type safety of a program based on analysis of a program's text (source code). If a program passes a static type checker, then the program is guaranteed to satisfy some set of type safety properties for all possible inputs.
https://en.wikipedia.org/wiki/Type_system#Static_type_checking
TL;DR it eliminates reduces bugs in your code
π
$ npm install -g flow-bin
$ flow bin
$ flow
Flow's "Hello World"
Other installation methods β https://flowtype.org/en/docs/install/
Demo: hello-world.js via CLI
My favourite way to run Flow...
π
π
...is with Nuclide
Also by Facebook...
Hello World in Atom + Nuclide
βοΈ
Demo: hello-world.js & hello-world-typed.js
Primitives
π§
Demo: primitives.js
Arrays
[π±,π±,π±]
Demo: arrays.js
Functions
π
Demo: functions.js
Classes
π«
Demo: classes.js
Aliases
π½
Demo: aliases.js
Modules
π±
Demo: modules.js
$ npm install -g flow-typed
$ npm install
$ flow-typed install
3rd party code
Demo: modules.js
The benefits of Flow for me
- The syntax is fairly simple
- You can integrate it into one file of a huge legacy project
- It actually helps reduce bugs
- It integrates with most tools you already use (Babel, CLI, etc...)
- Itβs self documenting
- Saves you pressing β+R alot
- Leaves less to worry about when updating code down the line
When to use Flow?
- Larger projects
- When multiple people are touching the code
- You anticipate refactoring
- Code you may come back to after a period of time
Team benefits Iβve already seen
πͺπ»
Bonus round
π
Amazing React support!
π©
Demo: react.js
@BenjaminReid
π
Flow
By Benjamin Reid
Flow
- 901