Skip to content

Expressions in propTypes not parsed correctly #36

Open
@mik01aj

Description

@mik01aj

Originally reported in styleguidist/react-styleguidist#13 (comment).

I use an expression in React.PropTypes.oneOf(...). This is the output from react-docgen:

{
  "description": "",
  "props": {
    "issue": {
      "type": {
        "name": "object"
      },
      "required": false,
      "description": ""
    },
    "width": {
      "type": {
        "name": "enum",
        "computed": true,
        "value": "_.map(_.keys(coverWidths), _.parseInt)" <------- problem
      },
      "required": false,
      "description": ""
    },
    "style": {
      "type": {
        "name": "object"
      },
      "required": false,
      "description": ""
    }
  }
}

coverWidths is a variable defined in that file. In runtime it's generated correctly, but react-docgen can't parse it.

value in the marked line should be null, and there should be a raw property with it instead.

@fkling confirmed that this is is a bug in react-docgen.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions