question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

create-react-app-with-flow example doesn't pass flow

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Following the example instructions for example should result in a project that passes Flow.

Current Behavior

  • Following directions results in many errors from “yarn flow”, the first of which is a reference to chai. Most of these errors are coming from code in node_modules.

After modifying .flowconfig to exclude all node_modules files, project still gets many errors. Here are the first few.

yarn run v1.6.0
$ flow
Error: src/pages/index.js:53
     v
 53:       <div className={this.props.classes.root}>
 54:         <Dialog open={this.state.open} onClose={this.handleClose}>
 55:           <DialogTitle>Super Secret Password</DialogTitle>
...:
 74:       </div>
           ^ children array. This type is incompatible with
 20:   | Iterable<React$Node>;
         ^^^^^^^^^^^^^^^^^^^^ $Iterable. See lib: /private/tmp/flow/flowlib_173ced39/react.js:20
  Property `@@iterator` is incompatible:
    197:     @@iterator(): Iterator<T>;
             ^^^^^^^^^^^^^^^^^^^^^^^^^ function type. This type is incompatible with. See lib: /private/tmp/flow/flowlib_173ced39/core.js:197
    503:     @@iterator(): $Iterator<Yield,Return,Next>;
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See lib: /private/tmp/flow/flowlib_173ced39/core.js:503
      The return is incompatible:
        197:     @@iterator(): Iterator<T>;
                               ^^^^^^^^^^^ $Iterator. Has some incompatible type argument with. See lib: /private/tmp/flow/flowlib_173ced39/core.js:197
        503:     @@iterator(): $Iterator<Yield,Return,Next>;
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ $Iterator. See lib: /private/tmp/flow/flowlib_173ced39/core.js:503
          Type argument `Yield` is incompatible:
             54:         <Dialog open={this.state.open} onClose={this.handleClose}>
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ React.Element. This type is incompatible with

Steps to Reproduce (for bugs)

git clone https://github.com/mui-org/material-ui.git mui
cd mui/examples/create-react-app-with-flow
yarn install
yarn global add flow-typed
flow-typed install
yarn flow
  • this is where you see the chai errors and many more from node_modules tree

Try modifying .flowconfig to exclude entire node_modules/ tree.

  • this is where you see the other errors

Context

It’s hard to use this as an example of using Flow with Material UI when it doesn’t pass Flow.

Your Environment

  "name": "create-react-app-with-flow",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "material-ui": "^1.0.0-beta.26",
    "prop-types": "^15.6.0",
    "react": "^16.0.0",
    "react-dom": "^16.0.0",
    "react-scripts": "^1.0.16"
  },
  "devDependencies": {
    "flow-bin": "^0.62.0"
  },

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
prastutcommented, Apr 23, 2018

@oliviertassinari updating flow type fixed the errors for me. Few ♥️ members of the community + me are contributing to the type defs as an when we fix them inside our codebase.

0reactions
rosskevincommented, Apr 23, 2018

My preference is to remove the flow example - the documentation already points to flow-typed, but if @prastut wants to PR the update that’s fine too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to incrementally add Flow to an existing React app
A simple process to follow is only to create libdefs as they are specifically required. For each component you are converting to use...
Read more >
What happens when a React app, which contains Flow ...
1 Answer 1 ... The reason it works is – create-react-app supports flow out of the box since it's using babel-preset-react which in...
Read more >
Troubleshooting Guide - React Flow
Troubleshooting. This guide contains warnings and errors that can occur when using React Flow. We are also adding common questions and pitfalls that...
Read more >
Adding Flow - Create React App
Run npm run flow init (or yarn flow init ) to create a .flowconfig file in the root directory. Add // @flow to...
Read more >
Integrating Flow into a React Project | by Ian Carlson | Medium
If you've already bought into the React ecosystem, then Flow is definitely worth a try. Using Atom and Nuclide provides first-class support ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found