Support React.Config
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with the functional-component example and its reported JSON output, then trace how react-docgen handles React.Config and destructured props. Done means the defaultProp, optionalProp, and requiredProp entries are all parsed with correct required and default-value metadata.
Written by the indexing model from the issue text.
Description
For functional components we can use React.Config to define default props:
import * as React from 'react';
type DefaultProps = $ReadOnly<{
/** Description for defaultProp. */
defaultProp: number,
}>;
type AllProps = $ReadOnly<{
...DefaultProps,
/** Description for optionalProp. */
optionalProp?: number,
/** Description for requiredProp. */
requiredProp: number,
}>;
type Props = React.Config<AllProps, DefaultProps>;
export default function Component({
defaultProp = 0,
optionalProp,
requiredProp,
}: Props) {
return <div />;
}
But react-docgen fails to parse all the props properly. It only parses the default prop but not the other two props.
{
"description": "",
"displayName": "Component",
"methods": [],
"props": {
"defaultProp": {
"defaultValue": {
"value": "0",
"computed": false
},
"required": false
},
"optionalProp": {
"defaultValue": {
"value": "0",
"computed": false
},
"required": false
}
}
}
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 316
- Avg merge
- 3h 28m
- Merged PRs (30d)
- 6
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.
More from reactjs/react-docgen
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
reactjs/react-docgen#1102 ·
-
Typescript Status Open
Difficulty 5/5 Over a week Newbie friendliness 20/100
reactjs/react-docgen#1005 · 4 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
reactjs/react-docgen#997 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
reactjs/react-docgen#994 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
reactjs/react-docgen#982 · 2 comments ·
All issues in reactjs/react-docgen
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
dennys-bd/agent-hive#184 ·
-
Add: hunch Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
AbdelStark/awesome-typesafe#104 ·
-
ai-observability bug team/ai-observability
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vicharanashala/fln#563 ·