This repository has been archived by the owner on Feb 17, 2022. It is now read-only.
[API Doc] Adds support for flow props types #49
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
react-docgen parses correctly propTypes annotated with FlowType, but Ecology does not use the resulting keys in the object passed as its
source
prop. Currently, the props of a component using only React.PropTypes without Flow types are displayed correctly for the JSDoc description and the required status, but no type is displayed.This pull request aims to provide support for FlowType-annotated props, by checking if there is a
flowType
key for the prop description it is rendering. It chooses to privilege flow proptypes over staticpropTypes
attribute, because Flow is more precise.There are three possible cases :
-
signature
type name (object shape or function) :We render the type's name + its raw annotation, for example :
object : {[id: string]: number}
orfunction : (value: string) => number
-
raw
type without signature (enum, array, union ...)We render the raw type annotation, for example :
Array<string>
- primitive types :
We render the type's name.
Related source code : getFlowType.js from react-docgen :
https://github.com/reactjs/react-docgen/blob/dca8ec9d57b4833f7ddb3164bedf4d74578eee1e/src/utils/getFlowType.js