Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gatsby-transformer-react-docgen): upgrade to react-docgen… (#16094)
- Loading branch information
1 parent
d5ba6cc
commit 16f7670
Showing
6 changed files
with
257 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
packages/gatsby-transformer-react-docgen/src/__tests__/__snapshots__/on-node-create.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`transformer-react-doc-gen: onCreateNode flowTypes should add flow type info: flow types 1`] = ` | ||
Array [ | ||
Object { | ||
"name": "number", | ||
}, | ||
Object { | ||
"elements": Array [ | ||
Object { | ||
"name": "literal", | ||
"value": "\\"string\\"", | ||
}, | ||
Object { | ||
"name": "literal", | ||
"value": "\\"otherstring\\"", | ||
}, | ||
Object { | ||
"name": "number", | ||
}, | ||
], | ||
"name": "union", | ||
"raw": "\\"string\\" | \\"otherstring\\" | number", | ||
}, | ||
Object { | ||
"elements": Array [ | ||
Object { | ||
"name": "any", | ||
}, | ||
], | ||
"name": "Array", | ||
"raw": "Array<any>", | ||
}, | ||
Object { | ||
"name": "signature", | ||
"raw": "(value: string) => void", | ||
"signature": Object { | ||
"arguments": Array [ | ||
Object { | ||
"name": "value", | ||
"type": Object { | ||
"name": "string", | ||
}, | ||
}, | ||
], | ||
"return": Object { | ||
"name": "void", | ||
}, | ||
}, | ||
"type": "function", | ||
}, | ||
Object { | ||
"name": "signature", | ||
"raw": "{ subvalue: ?boolean }", | ||
"signature": Object { | ||
"properties": Array [ | ||
Object { | ||
"key": "subvalue", | ||
"value": Object { | ||
"name": "boolean", | ||
"nullable": true, | ||
"required": true, | ||
}, | ||
}, | ||
], | ||
}, | ||
"type": "object", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`transformer-react-doc-gen: onCreateNode tsTypes should add TS type info: typescript types 1`] = ` | ||
Array [ | ||
Object { | ||
"name": "number", | ||
}, | ||
Object { | ||
"elements": Array [ | ||
Object { | ||
"name": "literal", | ||
"value": "string", | ||
}, | ||
Object { | ||
"name": "literal", | ||
"value": "otherstring", | ||
}, | ||
Object { | ||
"name": "number", | ||
}, | ||
], | ||
"name": "union", | ||
"raw": "\\"string\\" | \\"otherstring\\" | number", | ||
}, | ||
Object { | ||
"elements": Array [ | ||
Object { | ||
"name": "any", | ||
}, | ||
], | ||
"name": "Array", | ||
"raw": "Array<any>", | ||
}, | ||
Object { | ||
"name": "signature", | ||
"raw": "(value: string) => void", | ||
"signature": Object { | ||
"arguments": Array [ | ||
Object { | ||
"name": "value", | ||
"type": Object { | ||
"name": "string", | ||
}, | ||
}, | ||
], | ||
"return": Object { | ||
"name": "void", | ||
}, | ||
}, | ||
"type": "function", | ||
}, | ||
Object { | ||
"name": "signature", | ||
"raw": "{ subvalue: boolean }", | ||
"signature": Object { | ||
"properties": Array [ | ||
Object { | ||
"key": "subvalue", | ||
"value": Object { | ||
"name": "boolean", | ||
"required": true, | ||
}, | ||
}, | ||
], | ||
}, | ||
"type": "object", | ||
}, | ||
] | ||
`; |
27 changes: 27 additions & 0 deletions
27
packages/gatsby-transformer-react-docgen/src/__tests__/fixtures/typescript.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, { Component } from "react" | ||
|
||
interface Props { | ||
/** Description of prop "foo". */ | ||
primitive: number | ||
/** Description of prop "bar". */ | ||
literalsAndUnion: "string" | "otherstring" | number | ||
arr: Array<any> | ||
func?: (value: string) => void | ||
obj?: { subvalue: boolean } | ||
} | ||
|
||
const foo: number = 1 as const | ||
/** | ||
* General component description. | ||
*/ | ||
export default class MyComponent extends Component<Props, void> { | ||
props: Props | ||
|
||
render(): ReactElement { | ||
// ... | ||
} | ||
} | ||
|
||
export function Foo(props: Props) { | ||
return <div /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters