react-docgen
react-docgen copied to clipboard
Brace-only imports with elided semicolons breaks component description
I have this happening in a local project, but I was also able to reproduce it with a simple example in the playground. If you go to http://reactcommunity.org/react-docgen/ and paste in the following, the description shows up as empty:
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { Thing } from 'somewhere'
/**
* Sample doc for component.
*/
const Functional = (props) => {
return (<div>{props.foo}</div>)
}
Functional.propTypes = {
/**
* Description of prop "foo".
*/
foo: PropTypes.number
}
export default Functional
It only affects the first documentation comment, and then the parser flips back to a working state for whatever reason and properly parses the prop types.
Adding a semicolon, or rearranging the imports so a non-specific import is last in the order fixes it and the component description is parsed properly again.
Is this still a problem? I just tried on the website and it seems to be working. It might have to do with the version of @babel/parser you are using, try updating it to the latest version.