Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aurelienshz
Copy link

@aurelienshz aurelienshz commented Sep 12, 2016

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 static propTypes 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} or function : (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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant