Why you need Flow type - explained with images

Paritosh Pundir
2 min readNov 30, 2017

--

Flow is very similar to Typescript and is solving the same problem with a similar syntax. Flow can be easily used with any Javascript project without much refactoring. You also have control over which files you want to be type checked.

Now let’s try to pass some wrong values to see how Flow helps us keep a check on our code. It is a great help when we are dealing with a huge codebase or multiple developers are working on a same codebase.

  1. The key first accepts a string according to our type definition and we entered a number 2.
  2. We can see the text editor giving us a warning that the first key accepts a string.
  3. If we run the flow command in the terminal we can see where exactly things went wrong.

Where it helps the most

Using Flow, our code knows that name is an array and with any good text editor you can see the properties of an array pop as you type name.

These benefits are missing in a normal Javascript file without Flow. This is what you get while defining the function:

Here we have no support from our text editor and if we forget a property of an array we will have to seek help from Google 🤣

If you are still not sure about using Flow, just give it a shot and hopefully it will boost your Javascript workflow. Get Started with Flow (Flow.org)

--

--

Paritosh Pundir
Paritosh Pundir

Written by Paritosh Pundir

Founder of DoRemember.xyz. A productivity hacker on a mission to change the way we connect with ourselves.

No responses yet