Skip to content

Incorrectly processing recompose style HOCs #127

Description

@rosskevin

This is a little sticky so I'm debugging trying to figure out why. Ultimately, this was found because we aren't importing types from other files for object type spreads (issue #106), but it still doesn't seem like we should be visiting the options for a HOC.

Source file

import type { StyleSheetFactoryOptions } from 'jss/lib/types';

type Options = {
  withTheme?: boolean,
  name?: string,
  ...StyleSheetFactoryOptions,
};

function withStyles(
  stylesOrCreator: Object,
  options?: Options = {},
) {
  return (BaseComponent) => { ... }
}
TypeError: /Users/kross/projects/material-ui/src/styles/withStyles.js: Cannot read property 'forEach' of undefined
    at convertToPropTypes (/Users/kross/projects/material-ui/node_modules/babel-plugin-flow-react-proptypes/lib/convertToPropTypes.js:75:18)
    at /Users/kross/projects/material-ui/node_modules/babel-plugin-flow-react-proptypes/lib/convertToPropTypes.js:31:20
    at Array.forEach (<anonymous>)
    at convertToPropTypes (/Users/kross/projects/material-ui/node_modules/babel-plugin-flow-react-proptypes/lib/convertToPropTypes.js:27:21)
    at convertNodeToPropTypes (/Users/kross/projects/material-ui/node_modules/babel-plugin-flow-react-proptypes/src/index.js:28:40)
    at PluginPass.TypeAlias (/Users/kross/projects/material-ui/node_modules/babel-plugin-flow-react-proptypes/src/index.js:193:27)
    at newFn (/Users/kross/projects/material-ui/node_modules/babel-traverse/lib/visitors.js:276:21)
    at NodePath._call (/Users/kross/projects/material-ui/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (/Users/kross/projects/material-ui/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/Users/kross/projects/material-ui/node_modules/babel-traverse/lib/path/context.js:105:12)
    at TraversalContext.visitQueue (/Users/kross/projects/material-ui/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitMultiple (/Users/kross/projects/material-ui/node_modules/babel-traverse/lib/context.js:103:17)
    at TraversalContext.visit (/Users/kross/projects/material-ui/node_modules/babel-traverse/lib/context.js:190:19)
    at Function.traverse.node (/Users/kross/projects/material-ui/node_modules/babel-traverse/lib/index.js:114:17)
    at NodePath.visit (/Users/kross/projects/material-ui/node_modules/babel-traverse/lib/path/context.js:115:19)
    at TraversalContext.visitQueue (/Users/kross/projects/material-ui/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitSingle (/Users/kross/projects/material-ui/node_modules/babel-traverse/lib/context.js:108:19)
    at TraversalContext.visit (/Users/kross/projects/material-ui/node_modules/babel-traverse/lib/context.js:192:19)
    at Function.traverse.node (/Users/kross/projects/material-ui/node_modules/babel-traverse/lib/index.js:114:17)
    at traverse (/Users/kross/projects/material-ui/node_modules/babel-traverse/lib/index.js:79:12)

Are we agreed that we shouldn't visit HOC functions when resolving propTypes for react elements?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions