reactjs / reactjs/react-docgen
Using `Readonly<T>` utility type results in losing pieces of `T`'s information
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 316
- Avg merge
- 5h 7m
- Merged PRs (30d)
- 4
Description
You can paste the code below in the playground and see that description and tsType are lost.
interface Props {
/** The name to greet */
name: string
}
/**
* Hello world component
*/
const MyComponent = ({name = 'world'}: Props) => {
return <div />;
}
/**
* Hello world Readonly
*/
const MyReadonlyPropsComponent = ({name = 'world'}: Readonly<Props>)=> {
return <div />;
}
I noticed this behaviour while digging through an issue that appeared after the latest Storybook's major update, which uses this package by default to extract information from the components.
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 issue in the linked playground using the two component examples and compare the extracted results for Props and Readonly. The fix is complete when the Readonly result retains the prop description and tsType information shown for Props.
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
- Mostly clear
- Newbie friendliness
- 45/100