Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rvetere opened this issue May 29, 2024 · 1 comment
Open

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

rvetere opened this issue May 29, 2024 · 1 comment

Comments

@rvetere
Copy link
Contributor

rvetere commented May 29, 2024

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</>;
};
@michalkopanski
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants