Skip to content

Missing support for Pick<> and Omit<> #925

Open

Description

@rvetere

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</>;
};

Activity

  1. michalkopanski commented on Aug 7, 2024

    @michalkopanski

    Especially bummed about this one, because it works great up until the point we need to use either of these features.

    As we start to refactor our types and share them between components while using Pick<> or Omit<>, we also start to lose out on the benefit of having react-docgen in the first place.

  2. dimitur2204 commented on Sep 28, 2024

    @dimitur2204

    +1

  3. StefanFeser commented on Aug 28, 2025

    @StefanFeser

    We found out that using react-docgen-typescript instead of react-docgen CLI fixes this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions