-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question on flow support #9109
Comments
Yes, exactly. @rosskevin have been pushing forward the flow coverage of Material-UI. It's an ongoing effort. On the other hand. The TypeScript definitions have been primarily developed by @sebald and @pelotom. I'm personally not convinced by the overall advantages a type system is providing (in practice), so it's not something I'm prioritizing my time on. Still, any help is welcome to increase the typing coverage! |
@oliviertassinari Thks for the insight. I was really curious about the status. @sebald & @pelotom Thank you so much for the great support in TypeScript 👍🏻. |
I'm introducing flow to my own app source code, and as soon as I add |
Great, thanks @rosskevin! My bad, I should have noticed that from the website, since I browse it all the time. And to apply this to an existing app, what should be done? I tried copying over from this example app the folders Here's the single file where I have activated flow: // @flow
import React from 'react';
import { Link } from 'react-router-dom';
import { withStyles } from 'material-ui/styles';
import Button from 'material-ui/Button';
const styles = {
fab: {
position: 'fixed',
bottom: 36,
right: 36,
color: 'white',
zIndex: 1000,
},
};
export type Props = {
onClick: string | (Event => void),
icon: string,
classes: Object,
};
function Fab({ onClick, icon, classes }: Props) {
const isLink = typeof onClick !== 'function';
const buttonProps = isLink ? { component: Link, to: onClick } : { onClick };
return (
<Button fab color="accent" className={classes.fab} {...buttonProps}>
<i className="material-icons">{icon}</i>
</Button>
);
}
export default withStyles(styles)(Fab); As soon as I do that, when I run flow I get errors, these ones below:
|
@gnapse you will have to align your flow version with the exact version of the material-ui release. Note that I am no longer using flow for my project due to facebook/flow#5382 and am actively transitioning my project to use Typescript with material-ui |
Ok, thanks for the heads up and all the help. I'll see what I end up doing. Just a clarification: does this mean that material-ui won't ever have proper flow support? Is there a flow-typed library interface at least? And as a last resort, how could I tell flow to ignore material-ui completely? |
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 I just submitted a PR to update the docs/example with a warning: #9311 As a last resort, simply ignore I went through considerable pain to get it 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. |
Thanks for your time and all the information about this. It's unfortunate. The comment you cited in #9312 is also painfully revealing. I'll take a look at Typescript. |
Very disappointing from Flow. Time to look at Typescript for new projects I guess 😞 |
I would like to follow up on this thread. Has anyone be able to use |
@prastut has. |
@oliviertassinari I would really love to update the flow documentation so that more people like me do not face the same questions that I had faced. That involves discussion with the stance we document, since currently we kind of support it (since we have flow examples inside the repo etc.) but we also kind of don't (which is the stance our message could show) i.e: "Look folks, this is the reason why we dropped There are a couple of problems we also would need to address:
I am ready to put in all the effort that is needed so that we solve it once and for all, I hate to see the core team getting bothered with flow requests. The problem is of information asymmetry which we can easily solve through docs. |
@prastut @oliviertassinari Thanks for the feedback. I started to update the flow typings at https://github.com/flowtype/flow-typed/pull/2152/files. I hope that in the long run this type definition will be of good quality. |
@prastut This sounds like a great idea 💯.
This is something generic I feel with the typing systems. It's a personal opinion. It's not meant to deter people from using Flow or TypeScript. Ideally, it shouldn't impact how Material-UI support Flow and TypeScript.
We would definitely love to see that!!!
I think that we can clarify it through documentation. We don't have the ambition to provide a first-class support for Flow here, like we do with TypeScript. But we won't do any effort against Flow. |
I'm trying to build a flow type that is almost as good as the TS support but I'm looking for help because I'm not sure how to translate some of the utility TS types yet. I've put the current state at https://github.com/wcandillon/material-ui-flow. |
@wcandillon do you plan to support v3? |
@alexeyMohnatkin this has not changed:
Please look at the community efforts if you are interested in flow. |
First things first, thank you for your amazing work on the beta. The work you guys are doing is so important and I'm amazed to see that you are getting right. You are really setting a new defacto standard for React app. Not to get ahead of myself, I hope your work will spill over React Native maybe by strongly influencing another UI library or something, we'll see.
I recently gave another shot to flow and thought that I would try it with material-ui.
But it looks like the type definition is not as rich than in TS. For instance:
Doesn't look like
Theme
andStyleRules
are not defined in flow.How do develop the library? You write it in JavaScript and the TS definitions are written manually? I'm looking forward to learn more about this topic.
The text was updated successfully, but these errors were encountered: