reactjs / reactjs/react-docgen
Missing support for `Pick<>` and `Omit<>`
Open
Nobody has claimed this yet.
typescript
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 316
- Avg merge
- 5h 7m
- Merged PRs (30d)
- 4
Description
Whenever an interface is using the typescript features Pick or Omit, then we don't get any props from these interfaces/types.
In the case of an interface like this:
import { type LinkProps } from "next/link";
interface MyComponentProps
extends Pick<LinkProps, "prefetch" | "replace" | "scroll" | "shallow"> {
children?: React.ReactNode;
}
export const MyComponent: FunctionComponent<MyComponentProps> = () => {
return <>My Component</>;
};
-> in this case it will only find "children" as prop.
import { type LinkProps } from "next/link";
interface MyComponentProps
extends Pick<LinkProps, "prefetch" | "replace" | "scroll" | "shallow"> {
children?: React.ReactNode;
}
export const MyComponent: FunctionComponent<MyComponentProps> = () => {
return <>My Component</>;
};
The same with Omit<>:
import { type LinkProps } from "next/link";
interface MyComponentProps
extends Omit<LinkProps, "prefetch" | "replace" | "scroll" | "shallow"> {
children?: React.ReactNode;
}
export const MyComponent: FunctionComponent<MyComponentProps> = () => {
return <>My Component</>;
};
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
Start by reproducing the reported TypeScript examples using Pick and Omit, checking the extracted props for each interface. The work is done when props inherited through both utility types are included alongside explicitly declared props.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- next.js, react, typescript
- Domain
- developer-experience, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100