Skip to content

Commit

Permalink
[flow] fix HOC typing (hiding many errors) (#8419)
Browse files Browse the repository at this point in the history
* flow-typed update

* wow - HOCs seem to finally be typed correctly

* Cleanup, remaining errors seem to be related to withTheme

* [flow] refactor Placement in Tooltip

* [flow] Toolbar

* [flow] FormControl incorrect spec of Margin

* use react-flow-types HigherOrderComponent

* [flow] tabs

* [flow] SvgIcon

* [flow] labels and switches

* [flow] convert to flow typed more components

* re-enable GridWrapper with a flow fix me

* [withStyles] contextTypes defined twice - static inner and outer

* upgrade babel-plugin-flow-react-proptypes

* remove inline type imports - incompatible with current plugin

brigand/babel-plugin-flow-react-proptypes#134

* revert ListItemIcon dive change

* remove remaining $FlowFixMe Props|State
  • Loading branch information
rosskevin authored Sep 27, 2017
1 parent 958a67a commit 6f815c5
Show file tree
Hide file tree
Showing 188 changed files with 2,167 additions and 1,996 deletions.
2 changes: 0 additions & 2 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,3 @@ module.system.node.resolve_dirname=.
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe
suppress_comment= \\(.\\|\n\\)*\\$FlowExpectedError
suppress_type=$FlowToDo
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState
36 changes: 23 additions & 13 deletions docs/src/modules/components/Link.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow

import React from 'react';
import type { ElementType, Node } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import NextLink from 'next/link';
Expand Down Expand Up @@ -53,7 +54,27 @@ OnClick.propTypes = {
onCustomClick: PropTypes.func,
};

function Link(props, context) {
type Variant = 'default' | 'primary' | 'accent' | 'button';

type DefaultProps = {
classes: Object,
activeClassName: string,
variant: Variant,
};

type Props = {
activeClassName?: string,
children: Node,
classes?: Object,
className?: string,
component?: ElementType,
href?: string,
onClick?: Function,
prefetch?: boolean,
variant?: Variant,
};

function Link(props: DefaultProps & Props, context: Object) {
const {
activeClassName,
children: childrenProp,
Expand Down Expand Up @@ -113,18 +134,6 @@ function Link(props, context) {
return <ComponentRoot {...rootProps}>{children}</ComponentRoot>;
}

Link.propTypes = {
activeClassName: PropTypes.string,
children: PropTypes.node.isRequired,
classes: PropTypes.object.isRequired,
className: PropTypes.string,
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
href: PropTypes.string,
onClick: PropTypes.func,
prefetch: PropTypes.bool,
variant: PropTypes.oneOf(['default', 'primary', 'accent', 'button']),
};

Link.contextTypes = {
url: PropTypes.shape({
pathname: PropTypes.string.isRequired,
Expand All @@ -133,6 +142,7 @@ Link.contextTypes = {

Link.defaultProps = {
variant: 'default',
activeClassName: 'active',
};

export default withStyles(styles)(Link);
26 changes: 15 additions & 11 deletions docs/src/modules/components/MarkdownDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,20 @@ const styles = {
const demoRegexp = /^demo='(.*)'$/;
const SOURCE_CODE_ROOT_URL = 'https://github.com/callemall/material-ui/tree/v1-beta';

function MarkdownDocs(props, context) {
type DefaultProps = {
classes: Object,
};

type Props = {
classes?: Object,
demos?: { [key: string]: any },
markdown: string,
// You can define the direction location of the markdown file.
// Otherwise, we try to determine it with an heuristic.
sourceLocation?: string,
};

function MarkdownDocs(props: DefaultProps & Props, context: Object) {
const { classes, demos, markdown, sourceLocation: sourceLocationProp } = props;
const contents = getContents(markdown);
const components = getComponents(markdown);
Expand Down Expand Up @@ -63,7 +76,7 @@ function MarkdownDocs(props, context) {
{contents.map(content => {
const match = content.match(demoRegexp);

if (match) {
if (match && demos) {
const name = match[1];
warning(demos && demos[name], `Missing demo: ${name}.`);
return <Demo key={content} name={name} js={demos[name].js} raw={demos[name].raw} />;
Expand All @@ -86,15 +99,6 @@ ${components
);
}

MarkdownDocs.propTypes = {
classes: PropTypes.object.isRequired,
demos: PropTypes.object,
markdown: PropTypes.string.isRequired,
// You can define the direction location of the markdown file.
// Otherwise, we try to determine it with an heuristic.
sourceLocation: PropTypes.string,
};

MarkdownDocs.contextTypes = {
activePage: PropTypes.shape({
pathname: PropTypes.string.isRequired,
Expand Down
19 changes: 11 additions & 8 deletions docs/src/modules/components/MarkdownElement.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @flow

import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { withStyles } from 'material-ui/styles';
import marked from 'marked';
Expand Down Expand Up @@ -201,7 +200,17 @@ const styles = theme => ({
},
});

function MarkdownElement(props) {
type DefaultProps = {
classes: Object,
};

type Props = {
classes?: Object,
className?: string,
text: string,
};

function MarkdownElement(props: DefaultProps & Props) {
const { classes, className, text, ...other } = props;

/* eslint-disable react/no-danger */
Expand All @@ -215,10 +224,4 @@ function MarkdownElement(props) {
/* eslint-enable */
}

MarkdownElement.propTypes = {
classes: PropTypes.object.isRequired,
className: PropTypes.string,
text: PropTypes.string.isRequired,
};

export default withStyles(styles)(MarkdownElement);
2 changes: 1 addition & 1 deletion docs/src/pages/customization/CssInJs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @flow weak
/* eslint-disable flowtype/require-valid-file-annotation */

import React from 'react';
import PropTypes from 'prop-types';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/ThemeDefault.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ ThemeDefault.propTypes = {
theme: PropTypes.object.isRequired,
};

export default withTheme(ThemeDefault);
export default withTheme()(ThemeDefault);
2 changes: 1 addition & 1 deletion docs/src/pages/customization/WithTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ WithTheme.propTypes = {
theme: PropTypes.object.isRequired,
};

export default withTheme(WithTheme); // Let's get the theme as a property
export default withTheme()(WithTheme); // Let's get the theme as a property
4 changes: 2 additions & 2 deletions docs/src/pages/customization/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const theme = createMuiTheme({
});
```

### `withTheme(Component) => Component`
### `withTheme()(Component) => Component`

Provide the `theme` object as a property of the input component.

Expand All @@ -167,5 +167,5 @@ Provide the `theme` object as a property of the input component.
```js
import { withTheme } from 'material-ui/styles'

export default withTheme(MyComponent);
export default withTheme()(MyComponent);
```
4 changes: 2 additions & 2 deletions flow-typed/npm/@types/enzyme_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 5297e6bcf48dbbdf72036cf4f0e74a89
// flow-typed version: <<STUB>>/@types/enzyme_v^2.8.6/flow_v0.54.0
// flow-typed signature: 29861e245326601652e701f1ec9396ca
// flow-typed version: <<STUB>>/@types/enzyme_v^2.8.8/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/@types/react_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 4f4af6e9c348783f97a0f1c6d5d45158
// flow-typed version: <<STUB>>/@types/react_v^16.0.5/flow_v0.54.0
// flow-typed signature: 2b6b2a1fdf337b9e3981e2badf2331af
// flow-typed version: <<STUB>>/@types/react_v^16.0.5/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/app-module-path_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 607a1368ca8f07e70912bfc717c68d25
// flow-typed version: <<STUB>>/app-module-path_v^2.2.0/flow_v0.54.0
// flow-typed signature: 7201bed1395129adbf3102630e4cee3d
// flow-typed version: <<STUB>>/app-module-path_v^2.2.0/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/argos-cli_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 34b416b4b110731c3b0d5355b93034d4
// flow-typed version: <<STUB>>/argos-cli_v^0.0.9/flow_v0.54.0
// flow-typed signature: 5c96fcc02dcc5ee7d0d24caeba0b4343
// flow-typed version: <<STUB>>/argos-cli_v^0.0.9/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/autosuggest-highlight_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: b28cf07219661a2f609bca64cea51f85
// flow-typed version: <<STUB>>/autosuggest-highlight_v^3.1.0/flow_v0.54.0
// flow-typed signature: 370b0d9599ac5665a44a1230c6e45b28
// flow-typed version: <<STUB>>/autosuggest-highlight_v^3.1.0/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-cli_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 1f493e5516d71b03eecabc0eebe052b9
// flow-typed version: <<STUB>>/babel-cli_v^6.26.0/flow_v0.54.0
// flow-typed signature: 0b1433c9c4ad723e7948a8a9d4a096b9
// flow-typed version: <<STUB>>/babel-cli_v^6.26.0/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-core_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: fbac97e2af76b48d64f231fa852a001c
// flow-typed version: <<STUB>>/babel-core_v^6.26.0/flow_v0.54.0
// flow-typed signature: be442188d119c847416dd025f69bb123
// flow-typed version: <<STUB>>/babel-core_v^6.26.0/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-eslint_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: f2356761571c9811158ded04eecb6b34
// flow-typed version: <<STUB>>/babel-eslint_v^7.2.3/flow_v0.54.0
// flow-typed signature: 93147d4da81fabd80d03c1c949ceba89
// flow-typed version: <<STUB>>/babel-eslint_v^8.0.0/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-loader_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 4733e08b2785a36d58b073a2125dae3a
// flow-typed version: <<STUB>>/babel-loader_v^7.1.2/flow_v0.54.0
// flow-typed signature: 4206738fa1342398741edf5f8ddeb8c9
// flow-typed version: <<STUB>>/babel-loader_v^7.1.2/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-plugin-flow-react-proptypes_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: bd2e98c441b22de783ef0271c14ecd61
// flow-typed version: <<STUB>>/babel-plugin-flow-react-proptypes_v5.1.1/flow_v0.54.0
// flow-typed signature: 544c10d682689a1b2fa1f46488a14d8d
// flow-typed version: <<STUB>>/babel-plugin-flow-react-proptypes_v5.1.1/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-plugin-istanbul_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: bb051d78002020851a4990208b1df0d5
// flow-typed version: <<STUB>>/babel-plugin-istanbul_v^4.1.4/flow_v0.54.0
// flow-typed signature: c6f84fa56c03ca3db3be38634774e3a2
// flow-typed version: <<STUB>>/babel-plugin-istanbul_v^4.1.5/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-plugin-preval_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 30e1eeddfad780e4c986ea2355da9a4c
// flow-typed version: <<STUB>>/babel-plugin-preval_v^1.4.3/flow_v0.54.0
// flow-typed signature: 0157bd47438f31ceb8ab10278e42042f
// flow-typed version: <<STUB>>/babel-plugin-preval_v^1.5.0/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-plugin-react-remove-properties_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 581e3392539aee7d065405768334daa1
// flow-typed version: <<STUB>>/babel-plugin-react-remove-properties_v^0.2.5/flow_v0.54.0
// flow-typed signature: 84f4805566461e1f09cc4aed3e47bd19
// flow-typed version: <<STUB>>/babel-plugin-react-remove-properties_v^0.2.5/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-plugin-transform-dev-warning_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 1da21b94092059276fef2a2550adc983
// flow-typed version: <<STUB>>/babel-plugin-transform-dev-warning_v^0.1.0/flow_v0.54.0
// flow-typed signature: 6d7726d486013a75e50a21dfceb7885f
// flow-typed version: <<STUB>>/babel-plugin-transform-dev-warning_v^0.1.0/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 18448e153967f6a4e9cf83444380978e
// flow-typed version: <<STUB>>/babel-plugin-transform-flow-strip-types_v^6.22.0/flow_v0.54.0
// flow-typed signature: f5bc03436b1df48ac0553281d98fd24d
// flow-typed version: <<STUB>>/babel-plugin-transform-flow-strip-types_v^6.22.0/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-plugin-transform-object-assign_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 3eccd9596a6f9721bfd6836fcd79aba8
// flow-typed version: <<STUB>>/babel-plugin-transform-object-assign_v^6.22.0/flow_v0.54.0
// flow-typed signature: 4f5351be0a90943480f81d47de00bec5
// flow-typed version: <<STUB>>/babel-plugin-transform-object-assign_v^6.22.0/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: f875b10937f667a53ea53b3903bcb704
// flow-typed version: <<STUB>>/babel-plugin-transform-react-constant-elements_v^6.23.0/flow_v0.54.0
// flow-typed signature: c37ebd25a08f511db56ca913ccf98c88
// flow-typed version: <<STUB>>/babel-plugin-transform-react-constant-elements_v^6.23.0/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: cc6868c1ffa7133f793b9652e2ed10ce
// flow-typed version: <<STUB>>/babel-plugin-transform-react-remove-prop-types_v^0.4.8/flow_v0.54.0
// flow-typed signature: 200d5e6f9cd63e859e432d96ff7f3d47
// flow-typed version: <<STUB>>/babel-plugin-transform-react-remove-prop-types_v^0.4.8/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-plugin-transform-runtime_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 444692a55d3bf333204ccf63ffe333db
// flow-typed version: <<STUB>>/babel-plugin-transform-runtime_v^6.23.0/flow_v0.54.0
// flow-typed signature: 6d3cee82ddca0e5522f92f2f6a77eb50
// flow-typed version: <<STUB>>/babel-plugin-transform-runtime_v^6.23.0/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-polyfill_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 0efa92952ca816b2b986b25d63db58b0
// flow-typed version: <<STUB>>/babel-polyfill_v^6.26.0/flow_v0.54.0
// flow-typed signature: 3c3384b0284c1d461d772799ff65f778
// flow-typed version: <<STUB>>/babel-polyfill_v^6.26.0/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-preset-env_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 540ef9a53249d35de400ee694674816a
// flow-typed version: <<STUB>>/babel-preset-env_v^1.6.0/flow_v0.54.0
// flow-typed signature: 156e4ce8839874b7912495dd67fba8d3
// flow-typed version: <<STUB>>/babel-preset-env_v^1.6.0/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-preset-react_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: b3459381fbaca6e86efebc974cf3490f
// flow-typed version: <<STUB>>/babel-preset-react_v^6.24.1/flow_v0.54.0
// flow-typed signature: f71383ddec556db0dab5f719c4c0bb7d
// flow-typed version: <<STUB>>/babel-preset-react_v^6.24.1/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-preset-stage-1_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 62185b7fea83706d184e7c509a9f17c7
// flow-typed version: <<STUB>>/babel-preset-stage-1_v^6.24.1/flow_v0.54.0
// flow-typed signature: e8c59f853c9b6bca01994b640e9ddea7
// flow-typed version: <<STUB>>/babel-preset-stage-1_v^6.24.1/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-register_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: e3d8f3f1c6cb02d24bfc5c5095aef5b4
// flow-typed version: <<STUB>>/babel-register_v^6.26.0/flow_v0.54.0
// flow-typed signature: fea62fffe3130cc006825a4ae6f2c06a
// flow-typed version: <<STUB>>/babel-register_v^6.26.0/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-runtime_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 71f2042734f9a77038b8dfe377ec34e2
// flow-typed version: <<STUB>>/babel-runtime_v^6.26.0/flow_v0.54.0
// flow-typed signature: f6ed6d4faf45d15b895cbce7bc4a6fe8
// flow-typed version: <<STUB>>/babel-runtime_v^6.26.0/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/brcast_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: d498c9bb88b87dab14b6823fdf4727a0
// flow-typed version: <<STUB>>/brcast_v^3.0.1/flow_v0.54.0
// flow-typed signature: c9c2af232d0951a4bc449882d151b027
// flow-typed version: <<STUB>>/brcast_v^3.0.1/flow_v0.55.0

/**
* This is an autogenerated libdef stub for:
Expand Down
Loading

0 comments on commit 6f815c5

Please sign in to comment.