Flow

  • 3rd January 2017

Flow Cookbook: Flow & React

This recipe is part of the Flow Cookbook series. Flow and React are both Facebook projects - so as you might imagine, they work quite well together. React components can take type parameters to specify types for props and state. Type-checking works well with both functional and class components. Flow type annotations provide an alternative to propTypes runtime checks. Flow’s static checking has some advantages: Problems are reported immediately - it is not necessary to run tests that evaluate every component to identify props mismatches. Flow types can be more precise and concise than propTypes. Flow can also check state as well as props. In addition to checking that a component gets the correct props, Flow checks that props and states are used correctly within the component’s render method, and in other component methods. …

Read more 
  • 20th December 2016

Flow Cookbook: Unpacking JSON API data

A case study on using runtime validators to match incoming API data to Flow types

Read more 
  • 20th December 2016

Flow Cookbook

Type-checking can be a useful asset in a Javascript project. A type checker can catch problems that are introduced when adding features or refactoring, which can reduce the amount of time spent debugging and testing. Type annotations provide a form of always-up-to-date documentation that makes it easier for developers to understand an unfamiliar code base. But it is important to use type-checking effectively to get its full benefit. The Javascript community is fortunate to have a choice of two great type checkers. These recipes focus on Flow, and introduce patterns for using Flow effectively. …

Read more 
  • 31st May 2015

Advanced features in Flow

Flow has some very interesting features that are currently not documented. It is likely that the reason for missing documentation is that these features are still experimental. Caveat emptor. I took a stroll through the source code for Flow v0.11. Here is what I found while reading type_inference_js.ml and react.js. …

Read more 
  • 31st May 2015

Type checking React with Flow v0.11

This is an old post - for an up-to-date guide see Flow Cookbook: Flow & React. Flow v0.11 was released recently. The latest set of changes really improve type checking in React apps. But there are some guidelines to follow to get the full benefits. …

Read more 
  • 21st November 2014

Flow is the JavaScript type checker I have been waiting for

I am very excited about Flow, a new JavaScript type checker from Facebook. I have put some thought into what a type checker for JavaScript should do - and in my opinion Facebook gets it right. The designers of Flow took great effort to make it work well with JavaScript idioms, and with off-the-shelf JavaScript code. The key features that make that possible are type inference and path-sensitive analysis. I think that Flow has the potential to enable sweeping improvements to the code quality of countless web apps and Node apps. …

Read more