-
Notifications
You must be signed in to change notification settings - Fork 54
feat(utils): replace react-docgen with typescript #460
Conversation
Codecov Report
@@ Coverage Diff @@
## master #460 +/- ##
=========================================
+ Coverage 88.94% 89.2% +0.25%
=========================================
Files 41 41
Lines 1384 1417 +33
Branches 202 202
=========================================
+ Hits 1231 1264 +33
Misses 149 149
Partials 4 4
Continue to review full report at Codecov.
|
It seems that we can drop |
We will also need to correct some types |
# Conflicts: # src/components/Text/Text.tsx
package.json
Outdated
@@ -91,6 +91,7 @@ | |||
"lodash": "^4.17.10", | |||
"prop-types": "^15.6.1", | |||
"react-custom-scrollbars": "^4.2.1", | |||
"react-docgen-typescript": "^1.12.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, this should be in devDependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the catch! Moved.
-moving react-docgen-typescript to devDependencies
I also noticed that some Component are missing some common properties:
AccordionTitle
Attachment
Popup (maybe these shouldn't even be added, but just in case...)
Portal (maybe these shouldn't even be added, but just in case...)
Segment
Slot
Text
Using some common interface for these would help us avoiding some of these mistake, plus we would have consistent description for the common properties without having to copy paste the same thing, or change it everywhere if we decide for better description. |
# Conflicts: # src/components/Chat/ChatItem.tsx # src/components/Chat/ChatMessage.tsx # src/components/Segment/Segment.tsx # src/components/Slot/Slot.tsx
Future work:
|
RFC
This PR aims to replace react-docgen with alternative that will generate the info files for the components using the typescript interfaces. The PR introduces the react-docgen-typescript library, that out of the interfaces for the props of the component, generates json in the same format as the react-docgen library. I added one interface for the UIComponentProps with some common props that can be extended in the other component's props.
Example
For example, here is how the Button component prop section looks now, in comparison with the previous:
NOW
PREV
You can see that the types of the props are much descriptive with the new approach, but there are still some things that needs to be taken into account.
There is some bug I guess, because the types of the @params used inside the JSDoc are not picked up. I created issue for this on their github repo. In addition, the default value of the props are taken just if the value is some primitive type. However for the second, there is an alternative way of defining, by adding @default in the comment of the property.
Please share your feedback, so that we can make progress with this on the other components as well. @alinais @Bugaa92 @levithomason @kuzhelov @miroslavstastny @layershifter
Updated components