Skip to content

Commit

Permalink
Support memo, forwardRef and function expressions (atlassian#44)
Browse files Browse the repository at this point in the history
* Support memo and forwardRef

* Rename some tests and refactor some stuff

* Remove unnecessary checks

* Simplify logic a bit

* Change a thing to make a smaller diff

* Add changeset
  • Loading branch information
emmatown authored and Noviny committed Jan 23, 2019
1 parent 8f04dad commit 6bc521c
Show file tree
Hide file tree
Showing 5 changed files with 469 additions and 27 deletions.
16 changes: 16 additions & 0 deletions .changeset/d9bc5793/changes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"releases": [{ "name": "extract-react-types", "type": "minor" }],
"dependents": [
{
"name": "extract-react-types-loader",
"type": "patch",
"dependencies": ["extract-react-types"]
},
{ "name": "kind2string", "type": "patch", "dependencies": ["extract-react-types"] },
{
"name": "pretty-proptypes",
"type": "patch",
"dependencies": ["kind2string", "extract-react-types"]
}
]
}
1 change: 1 addition & 0 deletions .changeset/d9bc5793/changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Support memo, forwardRef and function expressions
241 changes: 241 additions & 0 deletions packages/extract-react-types/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,58 @@ Object {
}
`;

exports[`flow React.forwardRef 1`] = `
Object {
"component": Object {
"kind": "generic",
"value": Object {
"kind": "object",
"members": Array [
Object {
"key": Object {
"kind": "id",
"name": "ok",
},
"kind": "property",
"optional": false,
"value": Object {
"kind": "number",
},
},
],
"referenceIdName": "Props",
},
},
"kind": "program",
}
`;

exports[`flow React.memo 1`] = `
Object {
"component": Object {
"kind": "generic",
"value": Object {
"kind": "object",
"members": Array [
Object {
"key": Object {
"kind": "id",
"name": "ok",
},
"kind": "property",
"optional": false,
"value": Object {
"kind": "number",
},
},
],
"referenceIdName": "Props",
},
},
"kind": "program",
}
`;

exports[`flow any 1`] = `
Object {
"component": Object {
Expand Down Expand Up @@ -942,6 +994,32 @@ Object {
}
`;

exports[`flow forwardRef 1`] = `
Object {
"component": Object {
"kind": "generic",
"value": Object {
"kind": "object",
"members": Array [
Object {
"key": Object {
"kind": "id",
"name": "ok",
},
"kind": "property",
"optional": false,
"value": Object {
"kind": "number",
},
},
],
"referenceIdName": "Props",
},
},
"kind": "program",
}
`;

exports[`flow forwardRef default export 1`] = `
Object {
"component": Object {
Expand All @@ -968,6 +1046,39 @@ Object {
}
`;

exports[`flow forwardRef default export 2`] = `
Object {
"component": Object {
"kind": "generic",
"value": Object {
"kind": "object",
"members": Array [
Object {
"key": Object {
"kind": "id",
"name": "ok",
},
"kind": "property",
"optional": false,
"value": Object {
"kind": "number",
},
},
],
"referenceIdName": "Props",
},
},
"kind": "program",
}
`;

exports[`flow func that is not valid 1`] = `
Object {
"component": undefined,
"kind": "program",
}
`;

exports[`flow function 1`] = `
Object {
"component": Object {
Expand Down Expand Up @@ -1118,6 +1229,32 @@ Object {
}
`;

exports[`flow function expression 1`] = `
Object {
"component": Object {
"kind": "generic",
"value": Object {
"kind": "object",
"members": Array [
Object {
"key": Object {
"kind": "id",
"name": "ok",
},
"kind": "property",
"optional": false,
"value": Object {
"kind": "number",
},
},
],
"referenceIdName": "Props",
},
},
"kind": "program",
}
`;

exports[`flow function named params 1`] = `
Object {
"component": Object {
Expand Down Expand Up @@ -1569,6 +1706,110 @@ Object {
}
`;

exports[`flow memo 1`] = `
Object {
"component": Object {
"kind": "generic",
"value": Object {
"kind": "object",
"members": Array [
Object {
"key": Object {
"kind": "id",
"name": "ok",
},
"kind": "property",
"optional": false,
"value": Object {
"kind": "number",
},
},
],
"referenceIdName": "Props",
},
},
"kind": "program",
}
`;

exports[`flow memo default export 1`] = `
Object {
"component": Object {
"kind": "generic",
"value": Object {
"kind": "object",
"members": Array [
Object {
"key": Object {
"kind": "id",
"name": "ok",
},
"kind": "property",
"optional": false,
"value": Object {
"kind": "number",
},
},
],
"referenceIdName": "Props",
},
},
"kind": "program",
}
`;

exports[`flow memo wrapping forwardRef 1`] = `
Object {
"component": Object {
"kind": "generic",
"value": Object {
"kind": "object",
"members": Array [
Object {
"key": Object {
"kind": "id",
"name": "ok",
},
"kind": "property",
"optional": false,
"value": Object {
"kind": "number",
},
},
],
"referenceIdName": "Props",
},
},
"kind": "program",
}
`;

exports[`flow memo wrapping forwardRef default export 1`] = `
Object {
"component": Object {
"kind": "generic",
"value": Object {
"kind": "object",
"members": Array [
Object {
"key": Object {
"kind": "id",
"name": "ok",
},
"kind": "property",
"optional": false,
"value": Object {
"kind": "number",
},
},
],
"referenceIdName": "Props",
},
},
"kind": "program",
}
`;

exports[`flow mixed 1`] = `
Object {
"component": Object {
Expand Down
Loading

0 comments on commit 6bc521c

Please sign in to comment.