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.

Flow support is broken as of 0.57.0

See original GitHub issue

PR #9311 adds this:

Warning

An existing bug in flow regarding the use of higher order components (HOC) limits the usefulness of flow by an application. As of November 27, 2017 we cannot at this time recommend the use of flow typing in your application in conjunction with material-ui until such time as a resolution is present.

For those getting started, I want to make sure and warn them to avoid any unnecessary effort if possible.

Expected Behavior

Applications should be able to use flow typing with material-ui.

Current Behavior

Due to https://github.com/mui-org/material-ui/pull/9311, the flow bug prevents use of proper HOC typing as would be used by an application.

Context

From https://github.com/mui-org/material-ui/issues/9109#issuecomment-347283291

We cannot have proper flow support for apps since flow itself is broken. Since we cannot, not even an external libdef in flow-typed could have proper support. If we re-typed the HOCs to effectively any (as I discovered prior to #8419), you could pretend it had flow support, but we would have to do so knowing that we stopped static typing for almost everything. I found in #8419 with any HOCs, we were hiding 1700 flow errors! Essentially, we would have to make flow support almost useless.

Workaround

As a last resort, simply ignore material-ui in .flowconfig. If https://github.com/facebook/flow/issues/5382 remains unresolved for any amount of time, we will likely stop adding flow shadow files to the distribution, as it just makes every flow user ignore them. We aren’t sure yet, but it’s not a good situation.

Your Environment

Tech Version
Material-UI > v1.0.0-beta.21
Flow 0.57.0+

TL;DR

I went through considerable pain to get flow to work here and in our apps, only to have to abandon it. I have more invested with flow and material-ui than anyone, and I do think it says something important that I have chosen to abandon it for typescript. Now I think we should contemplate what this might mean for material-ui.

Next steps

TBD.

  1. I will not be continuing to maintain flow in material-ui, at least as it pertains to external use.
  2. @rsolomon did a good job with the latest PR to get us updated to 0.57+. He and others may be willing to step into the void I am leaving
  3. HOCs in flow are in a very fragile state, and I found unusable external to material-ui due to https://github.com/mui-org/material-ui/pull/9311. I am actually surprised that flow is currently working inside material-ui because I could not get the same patterns to work in my app after the flow 0.57+ update.

I am open to transitioning the source files to Typescript, and moving flow outside the library to flow-typed (also see #7857). If the maintainers are not going to be using flow, I would prefer to follow this path.

I’m open to all discussion, I just wanted to make this situation known to all.

/cc @rsolomon @oliviertassinari @mbrookes @pelotom @sebald @m2mathew

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:16 (15 by maintainers)

github_iconTop GitHub Comments

4reactions
prastutcommented, Mar 12, 2018

I am currently working on integrating MUI with a codebase that uses Flow for type checking. During my research on how to workaround Flow errors, I went through issue 9312 and PR 9453 (Not referencing them as don’t want unnecessary bubbling up of Github thread). I completely understand why you would drop flow support.

I see that some of the flow maintainers did try to reach out here: but I guess it was too late by then.

But one thing I was not able to find in MUI’s documentation for flow is the current state of how devs can integrate MUI with an existing codebase that uses flow. Our codebase uses other HOC libraries as well like recompose so I am not sure how best I can ignore flow errors from Material UI but let the rest of the code getting type checked. Moving to Typescript on our end would be a very drastic step, therefore some clarity would help.

I am more than happy to update the documentation if I have some clarity myself. Right now it looks as if the docs tell that we do support Flow but with a warning, but my experience reading all of the above links suggest that you have completely done away with Flow.

@rsolomon provides some information but it’s lost in terms of getting context for a third person like me.

cc: @rosskevin

3reactions
rosskevincommented, Dec 12, 2017

For watchers - we are actively dropping flow support.

With the broken state of flow, we cannot in good conscience distribute flow files here - we feel it gives the mistaken impression of coverage when we know well at this point that too many implicit anys due to poor hoc support.

Community flow-typed definition?

If you are interested in maintaining a flow-typed definition, please let the community know so perhaps you may join forces together. With our current sentiment regarding flow, we have decided we will not distribute any flow files from this hosted repository. It is probably best that you take a branch of what is current on v1-beta before #9453 is merged so that you may copy existing definitions out of source into a libdef.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Release Notes - FastAPI
This version of FastAPI drops support for Python 3.6. ... of oauth2-redirect.html to include fixes for flavors of authorization code flows in Swagger...
Read more >
rollup changelog
Fix a situation where invalid code was rendered when dynamically importing a module with synthetic named exports when preserving modules (#3738) ...
Read more >
Changelog | Linode Developer Tools
Support for Block Storage migrations and flow for upgrading volumes to NVMe ... (/object-storage) endpoints contained broken links to S3 API documentation.
Read more >
Blog · React Native
Added support for Android, previously iOS-only. ... community sent ~40 Pull Requests to complete this work for flow typed native modules.
Read more >
Vega software releases | Vega Protocol Documentation
In the future, support will be required for other options, such as permanently approve or ... For full details see the vega core...
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