Skip to content

Instantly share code, notes, and snippets.

@didi0613
Last active June 22, 2018 23:18
Show Gist options
  • Save didi0613/5fc88a31899872ac53cbe54742976120 to your computer and use it in GitHub Desktop.
Save didi0613/5fc88a31899872ac53cbe54742976120 to your computer and use it in GitHub Desktop.
How to add flow to existing electrode app

How to add flow to existing electrode app

Flow is a static type checker for Javascript and widely used by frontend developers nowadays. It helps us to code faster, smarter, bigger and more confidently. Since Electrode has already got Babel in place, we need to set up flow with babel: using babel to compile the code and integrate Flow into Electrode app.

Steps

If you wants to add Flow with the existing app, here is what you'll need to do:

  • update package.json:

    update electrode-archetype-react-app* version:

    "electrode-archetype-react-app": "^5.3.0"
    "electrode-archetype-react-app-dev": "^5.3.0"
    

    add flow as to your script:

    "flow": "flow"
    

    Delete node_modules and re-install the dependencies after the changes above.

  • initiate Flow

    If it is your first time to run Flow, initiate your project with clap initflow.

  • Prepare your code for Flow

    To mark the flow files, you can place the following before any code in Javascript files.

    // @flow
    

    or

    /* @flow */
    

    This flag is in the form of a normal JavaScript comment annotated with @flow. The Flow background process gathers all the files with this flag and uses the type information available from all of these files to ensure consistency and error free programming.

  • Check your code

    If you wants to run the Flow Background Process, you can start the process that allows Flow to check your code incrementally and with great speed by:

    flow status
    

    To stop the background process, run flow stop.

    You can also type flow to accomplish the same effect as status is the default flag to the flow binary. At any point that you want to check for errors, just run:

    npm run flow
    
@datvong-wm
Copy link

Should move to electrode-dev-guide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment