reactjs / reactjs/react-docgen
@defaultValue is not parsed from interface
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 316
- Avg merge
- 5h 7m
- Merged PRs (30d)
- 4
Description
The following code tested in the playgroud https://react-docgen.dev/playground
interface Props {
/**
* The name to greet
*
* @defaultValue 'something'
*/
name: string;
}
/**
* Hello world component
*/
const MyComponent = (props: Props) => {
return <div />;
}
returns:
[
{
"description": "Hello world component",
"displayName": "MyComponent",
"methods": [],
"props": {
"name": {
"required": true,
"tsType": {
"name": "string"
},
"description": "The name to greet\n\n@defaultValue 'something'"
}
}
}
]
I think the defaultValue property is missing and should appear in the result, and part of the description "@defaultValue 'something'" should be removed.
[
{
"description": "Hello world component",
"displayName": "MyComponent",
"methods": [],
"props": {
"name": {
"required": true,
"tsType": {
"name": "string"
},
"description": "The name to greet",
"defaultValue": {
"value": "'something'",
"computed": false
}
}
}
}
]
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 interface example in the react-docgen playground and inspect how its JSDoc tags are parsed. Confirm that @defaultValue is removed from the description and emitted as a non-computed defaultValue with the expected value; use the shown output as the completion check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100