Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docgen): add a friendly exception #2348

Merged
merged 1 commit into from
Dec 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gulp/plugins/gulp-react-docgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default (filename) => {
// replace prop `description` strings with a parsed doc block object and updated `type`
_.each(parsed.props, (propDef, propName) => {
const { description, tags } = parseDocBlock(propDef.description)
const { name, value } = parseType(propDef)
const { name, value } = parseType(propName, propDef)

parsed.props[propName] = {
...propDef,
Expand Down
9 changes: 8 additions & 1 deletion gulp/plugins/util/parseType.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ const parsers = {
union: parseUnion,
}

export default ({ type }) => {
export default (propName, { type }) => {
if (type === undefined) {
throw new Error([
`The prop "${propName}" does not contain propType definition. This happens if the property is in the `,
'defaultProps, but it is not in the propTypes',
].join(' '))
}

const parser = parsers[type.name]

return parser ? parser(type) : type
Expand Down