Skip to content

Commit

Permalink
[flow] Upgrade to flow 0.53.1 (#7869)
Browse files Browse the repository at this point in the history
* [flow] upgrade flow-bin

* [flow] initial flow-upgrade

- ran flow-upgrade
- switch React.Element<any> references to React.Node
- switch all react imports to `* as React` and use the React.* for access to uniformly access both function and types
- linted

* [flow] flow-typed install

* [flow] flow-typed workaround marked libdef

flow-typed/flow-typed#1165

* [flow] flow-upgrade ./test

* [flow] fix flow usage of WebkitTran*

* [flow] type single-only children for transitions

* [flow] woohoo, resolved sticky Snackbar flow typing

* [flow] more 53.1 typing

* [Card] flow fixes #7854

* [flow] more flow 53.1

* [flow] fixme for #7868

* [flow] 53.1 ./examples

* [flow] weak type docs for 53.1

* [flow] flow-typed workaround for flow-typed/flow-typed#1158

* [flow] workaround for flow-typed/flow-typed#1158

* [flow] require Dialog element

* [flow] convert withStyles to flow

* [flow] workaround brigand/babel-plugin-flow-react-proptypes#127

This isn’t a fix, it just gets past the error.  I assume generated prop types are still invalid.

* [flow] type TouchRipple and Ripple

* [flow] type withTheme

* [flow] type HOC withTheme

* [flow] bind hoc BaseProps

* [flow] type withWidth

* [flow] type Tabs

* [flow] correct requirements for HOC props

* [flow] 0.53.1 conversion - tests finally run with a few errors

* [flow] FormControl children were tested as optional

* [Textarea] revert to target instead of currentTarget

* [docs] Fix missing props in css-in-js examples (#7867)

* [docs] Fix missing props in css-in-js examples

`this.classes.root` wouldn't work - `this.props.classes.root' would.

* Update css-in-js.md

* [flow] get docs working

* [Tabs] fix flow change that broke tab movement

* [flow] reduce DefaultProps usage to the minimum necessary

* [flow] type callback on ButtonBase

* [docs] workaround react-docgen #7780

* Temporary size limit increase due to #7881
  • Loading branch information
rosskevin authored Aug 23, 2017
1 parent a0a4adb commit 470a825
Show file tree
Hide file tree
Showing 486 changed files with 8,581 additions and 1,897 deletions.
15 changes: 9 additions & 6 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[ignore]

<PROJECT_ROOT>/build
.*/node_modules/react-event-listener/src/.*
.*/node_modules/react-event-listener
.*/node_modules/fbjs/lib/partitionObjectByKey.js
.*/node_modules/jss/lib/.*\.js\.flow
.*/node_modules/mitt/src/.*\.js
.*/node_modules/react-swipeable-views/src/.*
.*/node_modules/eslint-plugin-jsx-a11y/src/.*
.*/scripts/*
.*/node_modules/mitt
.*/node_modules/react-swipeable-views
.*/node_modules/eslint-plugin-jsx-a11y
.*/scripts
.*/docs/webpack.*
; FIXME: we should be flow checking against jss
.*/node_modules/jss/lib/.*\.js\.flow

[libs]

Expand All @@ -32,3 +33,5 @@ module.system.node.resolve_dirname=.
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe
suppress_comment= \\(.\\|\n\\)*\\$FlowExpectedError
suppress_type=$FlowToDo
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState
4 changes: 4 additions & 0 deletions docs/scripts/buildApiES5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @flow

require('babel-register');
require('./buildApi');
2 changes: 1 addition & 1 deletion docs/src/modules/components/AppContent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import React from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { withStyles } from 'material-ui/styles';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/AppDrawer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import React from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from 'material-ui/styles';
import List from 'material-ui/List';
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/components/AppDrawerNavItem.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import React, { Component } from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import Link from 'docs/src/modules/components/Link';
import classNames from 'classnames';
Expand Down Expand Up @@ -44,7 +44,7 @@ const styles = theme => ({
},
});

class AppDrawerNavItem extends Component {
class AppDrawerNavItem extends React.Component<any, any> {
static defaultProps = {
openImmediately: false,
};
Expand Down
5 changes: 3 additions & 2 deletions docs/src/modules/components/AppFrame.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import React, { Component } from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import compose from 'recompose/compose';
Expand Down Expand Up @@ -102,7 +102,8 @@ const styles = theme => ({
},
});

class AppFrame extends Component {
class AppFrame extends React.Component<any, any> {
static defaultProps: $FlowFixMeProps;
state = {
drawerOpen: false,
};
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/AppSearch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import React from 'react';
import * as React from 'react';
import compose from 'recompose/compose';
import pure from 'recompose/pure';
import PropTypes from 'prop-types';
Expand Down
5 changes: 3 additions & 2 deletions docs/src/modules/components/AppWrapper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow weak
/* eslint-disable no-underscore-dangle */

import React, { Component } from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import { JssProvider } from 'react-jss';
import { getContext } from 'docs/src/modules/styles/context';
Expand All @@ -25,7 +25,8 @@ if (process.browser && !global.__INSERTION_POINT__) {
}
}

class AppWrapper extends Component {
class AppWrapper extends React.Component<any, any> {
static defaultProps: $FlowFixMeProps;
componentWillMount() {
this.styleContext = getContext();
}
Expand Down
5 changes: 3 additions & 2 deletions docs/src/modules/components/Demo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import React, { Component } from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from 'material-ui/styles';
import IconButton from 'material-ui/IconButton';
Expand Down Expand Up @@ -54,7 +54,8 @@ const styles = theme => ({
},
});

class Demo extends Component {
class Demo extends React.Component<any, any> {
static defaultProps: $FlowFixMeProps;
state = {
codeOpen: false,
};
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/Github.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
/* eslint-disable max-len */

import React from 'react';
import * as React from 'react';
import SvgIcon from 'material-ui/SvgIcon';

function GitHub(props: Object) {
Expand Down
5 changes: 3 additions & 2 deletions docs/src/modules/components/Link.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import React, { Component } from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import NextLink from 'next/link';
Expand Down Expand Up @@ -30,7 +30,8 @@ const styles = theme => ({
},
});

class OnClick extends Component {
class OnClick extends React.Component<any, any> {
static defaultProps: $FlowFixMeProps;
handleClick = event => {
if (this.props.onClick) {
this.props.onClick(event);
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/MarkdownDocs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import React from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import kebabCase from 'lodash/kebabCase';
import warning from 'warning';
Expand Down
3 changes: 2 additions & 1 deletion docs/src/modules/components/MarkdownElement.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import React from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { withStyles } from 'material-ui/styles';
Expand Down Expand Up @@ -33,6 +33,7 @@ marked.setOptions({
sanitize: false,
smartLists: true,
smartypants: false,
// $FlowFixMe
highlight(code) {
return prism.highlight(code, prism.languages.jsx);
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/Twitter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
/* eslint-disable max-len */

import React from 'react';
import * as React from 'react';
import SvgIcon from 'material-ui/SvgIcon';

function Twitter(props: Object) {
Expand Down
30 changes: 15 additions & 15 deletions docs/src/modules/components/withRoot.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow weak

import React, { Component } from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import { Provider } from 'react-redux';
import pure from 'recompose/pure';
Expand Down Expand Up @@ -169,16 +169,27 @@ function findActivePage(currentPages, url) {
return activePage;
}

function withRoot(BaseComponent) {
function withRoot<BaseProps: {}>(BaseComponent: React.ComponentType<BaseProps>) {
// Prevent rerendering
const PureBaseComponent = pure(BaseComponent);

class WithRoot extends Component {
type WithRootProps = {
reduxServerState?: Object,
url: Object,
};
class WithRoot extends React.Component<WithRootProps> {
props: WithRootProps;
static childContextTypes = {
url: PropTypes.object,
pages: PropTypes.array,
activePage: PropTypes.object,
};
static getInitialProps(ctx) {
let initialProps = {};
const redux = initRedux({});

if (BaseComponent.getInitialProps) {
// $FlowFixMe - a next component signature?
const baseComponentInitialProps = BaseComponent.getInitialProps({ ...ctx, redux });
initialProps = {
...baseComponentInitialProps,
Expand All @@ -200,7 +211,7 @@ function withRoot(BaseComponent) {

constructor(props) {
super(props);
this.redux = initRedux(this.props.reduxServerState);
this.redux = initRedux(this.props.reduxServerState || {});
}

getChildContext() {
Expand Down Expand Up @@ -228,17 +239,6 @@ function withRoot(BaseComponent) {
WithRoot.displayName = wrapDisplayName(BaseComponent, 'withRoot');
}

WithRoot.propTypes = {
reduxServerState: PropTypes.object,
url: PropTypes.object.isRequired,
};

WithRoot.childContextTypes = {
url: PropTypes.object,
pages: PropTypes.array,
activePage: PropTypes.object,
};

return WithRoot;
}

Expand Down
20 changes: 19 additions & 1 deletion docs/src/modules/utils/generateMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ function getDeprecatedInfo(type) {
function generatePropDescription(description, type) {
let deprecated = '';

// FIXME: unsupported flow props from 0.53.x upgrade
// https://github.com/reactjs/react-docgen/issues/207
if (type === undefined) {
return '';
}

if (type.name === 'custom') {
const deprecatedInfo = getDeprecatedInfo(type);

Expand Down Expand Up @@ -86,6 +92,12 @@ function generatePropDescription(description, type) {
}

function generatePropType(type) {
// FIXME: unsupported flow props from 0.53.x upgrade
// https://github.com/reactjs/react-docgen/issues/207
if (type === undefined) {
return '';
}

switch (type.name) {
case 'func':
return 'function';
Expand Down Expand Up @@ -146,6 +158,12 @@ function generateProps(reactAPI) {
| Name | Type | Default | Description |
|:-----|:-----|:--------|:------------|\n`;

// FIXME: unsupported flow props from 0.53.x upgrade
// https://github.com/reactjs/react-docgen/issues/207
if (reactAPI.props === undefined) {
return text;
}

text = Object.keys(reactAPI.props).sort().reduce((textProps, propRaw) => {
const prop = getProp(reactAPI.props, propRaw);
const description = generatePropDescription(prop.description, prop.flowType || prop.type);
Expand All @@ -165,7 +183,7 @@ function generateProps(reactAPI) {
}

const type = prop.flowType || prop.type;
if (type.name === 'custom') {
if (type && type.name === 'custom') {
if (getDeprecatedInfo(prop.type)) {
propRaw = `~~${propRaw}~~`;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/BusinessVariables.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow weak

import React from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import Checkbox from 'material-ui/Checkbox';
import { createMuiTheme, MuiThemeProvider, withStyles } from 'material-ui/styles';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/CssInJs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow weak

import React from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { withStyles } from 'material-ui/styles';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/DarkTheme.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow weak

import React from 'react';
import * as React from 'react';
import { MuiThemeProvider, createMuiTheme } from 'material-ui/styles';
import createPalette from 'material-ui/styles/palette';
import WithTheme from './WithTheme';
Expand Down
5 changes: 3 additions & 2 deletions docs/src/pages/customization/JssRegistry.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// @flow weak

import React, { Component } from 'react';
import * as React from 'react';
import { JssProvider, SheetsRegistry } from 'react-jss';
import { createMuiTheme, MuiThemeProvider } from 'material-ui/styles';
import CssInJs from './CssInJs';

const sheetsRegistry = new SheetsRegistry();
const theme = createMuiTheme();

class JssRegistry extends Component {
class JssRegistry extends React.Component<any, any> {
static defaultProps: {};
state = {
length: 0,
};
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/Nested.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow weak

import React from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import Checkbox from 'material-ui/Checkbox';
import { createMuiTheme, MuiThemeProvider, withStyles } from 'material-ui/styles';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/OverridesClassNames.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow weak

import React from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from 'material-ui/styles';
import Button from 'material-ui/Button';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/OverridesClasses.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow weak

import React from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from 'material-ui/styles';
import Button from 'material-ui/Button';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/OverridesComponent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow weak

import React from 'react';
import * as React from 'react';
import OverridesClassNames from 'docs/src/pages/customization/OverridesClassNames';

// We can use OverridesClassNames over and over.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/OverridesInlineStyle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow weak

import React from 'react';
import * as React from 'react';
import Button from 'material-ui/Button';

// We can use inline-style
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/OverridesTheme.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow weak

import React from 'react';
import * as React from 'react';
import { MuiThemeProvider, createMuiTheme } from 'material-ui/styles';
import Button from 'material-ui/Button';

Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/Palette.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow weak

import React from 'react';
import * as React from 'react';
import { MuiThemeProvider, createMuiTheme } from 'material-ui/styles';
import createPalette from 'material-ui/styles/palette';
import purple from 'material-ui/colors/purple';
Expand Down
Loading

0 comments on commit 470a825

Please sign in to comment.