Skip to content

Commit 277b0be

Browse files
emmatownNoviny
authored andcommitted
Add babel-plugin-extract-react-types (#47)
* Mostly done babel plugin, still ts support to fix * Fix ts support * Improve type system detection * Remove ComponentProps component and add component prop to Props component
1 parent 3299e3a commit 277b0be

File tree

17 files changed

+1512
-118
lines changed

17 files changed

+1512
-118
lines changed

.changeset/40ff523e/changes.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"releases": [{ "name": "extract-react-types", "type": "minor" }],
3+
"dependents": [
4+
{
5+
"name": "babel-plugin-extract-react-types",
6+
"type": "patch",
7+
"dependencies": ["extract-react-types"]
8+
},
9+
{
10+
"name": "extract-react-types-loader",
11+
"type": "patch",
12+
"dependencies": ["extract-react-types"]
13+
},
14+
{ "name": "kind2string", "type": "patch", "dependencies": ["extract-react-types"] },
15+
{
16+
"name": "pretty-proptypes",
17+
"type": "patch",
18+
"dependencies": ["kind2string", "extract-react-types"]
19+
}
20+
]
21+
}

.changeset/40ff523e/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add findExportedComponents function

.changeset/96dc821d/changes.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "releases": [{ "name": "pretty-proptypes", "type": "minor" }], "dependents": [] }

.changeset/96dc821d/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add component prop to Props component

.changeset/dd3cc83e/changes.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "releases": [{ "name": "babel-plugin-extract-react-types", "type": "minor" }], "dependents": [] }

.changeset/dd3cc83e/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add babel-plugin-extract-react-types

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
"dependencies": {
1818
"@atlaskit/build-releases": "^3.0.3",
1919
"@babel/core": "7.0.0-beta.56",
20+
"@babel/plugin-syntax-flow": "^7.2.0",
21+
"@babel/plugin-syntax-jsx": "^7.2.0",
22+
"@babel/plugin-syntax-typescript": "^7.2.0",
2023
"@babel/types": "^7.0.0-beta.56",
2124
"ast-pretty-print": "^2.0.1",
2225
"babel-errors": "^1.1.1",
@@ -59,6 +62,7 @@
5962
"enzyme-adapter-react-16": "^1.1.1",
6063
"flow-bin": "^0.69.0",
6164
"jest": "^23.6.0",
65+
"jest-in-case": "^1.0.2",
6266
"jsdom": "^11.7.0",
6367
"prettier": "^1.13.7",
6468
"react": "^16.3.1",
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# babel-plugin-extract-react-types
2+
3+
> A Babel plugin to store the types of React components as a property on the component for documentation
4+
5+
## Install
6+
7+
```bash
8+
yarn add babel-plugin-extract-react-types pretty-proptypes
9+
```
10+
11+
## Usage
12+
13+
`.babelrc`
14+
15+
```json
16+
{
17+
"plugins": ["babel-plugin-extract-react-types"]
18+
}
19+
```
20+
21+
```jsx
22+
import SomeComponent from 'somewhere';
23+
import Props from 'pretty-proptypes';
24+
25+
<Props heading="My Component" component={SomeComponent} />;
26+
```
27+
28+
## Inspiration
29+
30+
- [babel-plugin-react-docgen](https://github.com/storybooks/babel-plugin-react-docgen)

0 commit comments

Comments
 (0)