reactjs / reactjs/react-docgen
Confused react type names on Flow and Typescript
Open
Nobody has claimed this yet.
breaking
bug
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 316
- Avg merge
- 5h 7m
- Merged PRs (30d)
- 4
Description
Hi, I try convert react-docgen props to JSON-schema. But in typescript and flow, we get different names by different ways to program.Just like this. This ReactReactNode makes me so confused. How should i do with it ?
import React, { ReactNode, Component } from 'react';
interface Props {
content: ReactNode,
children: React.ReactNode,
}
class TSReactComponent extends Component<Props> {
render() {
return (
<div>hello world</div>
);
}
}
export default TSReactComponent;
react-docgen result
{
"description": "",
"displayName": "TSReactComponent",
"methods": [],
"props": {
"content": {
"required": true,
"flowType": {
"name": "ReactNode"
},
"description": ""
},
"children": {
"required": true,
"flowType": {
"name": "ReactReactNode",
"raw": "React.ReactNode"
},
"description": ""
}
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the TypeScript example and inspect the parser path that produces the shown props JSON for ReactNode and React.ReactNode. Compare the Flow and TypeScript results, then verify that the reported type names are handled consistently without regressing the existing output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- devtools, documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100