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

Ability to exclude some chained prop types #10371

Closed
mustran opened this issue Apr 9, 2020 · 10 comments
Closed

Ability to exclude some chained prop types #10371

mustran opened this issue Apr 9, 2020 · 10 comments

Comments

@mustran
Copy link

mustran commented Apr 9, 2020

Is your feature request related to a problem? Please describe.
I am trying to generate docs for a library and suddenly I got into a problem where I can't exclude some inherited types (props) from TypeScript.

TypeScript types:

type ContentProps = {
  icon?: ReactNode | null;
  iconPosition?: string;
  children?: any;
};

export type Props = ButtonHTMLAttributes<HTMLButtonElement> &
  ContentProps & {
    buttonModifiers?: Array<string>;
    sizeType?: Size;
    style?: CSSProperties;
    className?: string;
    fullWidth?: boolean;
    fullHeight?: boolean;
  };

Button Component:

const Button = (props: Props) => ()

Describe the solution you'd like
I want to be able to remove the props from HTMLButtonElement so it shows only the ContentProps and the other defined props (buttonModifiers,sizeType etc).

Describe alternatives you've considered
None.

Are you able to assist bring the feature to reality?
maybe ..

Screenshot

Screenshot from 2020-04-09 21-39-29

@shilman
Copy link
Member

shilman commented Apr 11, 2020

Sort of dupe to #7943

@mustran
Copy link
Author

mustran commented Apr 12, 2020

@shilman As I can see, the issue is still opened which means that there is still no support for this feature ? If that is the case, in which version we should expect this feature to be available ?

@shilman
Copy link
Member

shilman commented Apr 12, 2020

@mustran Either 6.0, which should be stable by mid-May, or 6.1, which should be stable mid-Summer.

@stale
Copy link

stale bot commented May 4, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label May 4, 2020
@shilman
Copy link
Member

shilman commented May 4, 2020

A workaround I've added is the ability to specify props include and exclude:

type PropDescriptor = string[] | RegExp;

interface BaseProps {
  include?: PropDescriptor;
  exclude?: PropDescriptor;
}

So you could achieve what you want by only including non-chained props. E.g.:

const include = ['buttonModifiers', 'sizeType', 'style', 'className', 'fullWidth', 'fullHeight'];

<Props of={Button} include={include} />;

@mustran
Copy link
Author

mustran commented May 4, 2020

Hi @shilman. Thank you a lot for your answer, it looks amazing.
Is the feature available in the beta version ?

@shilman
Copy link
Member

shilman commented May 4, 2020

@mustran Yeah, available for a couple weeks #10464

LMK if that works for you!

@mustran
Copy link
Author

mustran commented May 4, 2020

@shilman I deleted node_modules, installed the beta version and when I run yarn run storybook I get this error:

Screenshot from 2020-05-04 15-07-56

Also, this is how my scripts are defined:

Screenshot from 2020-05-04 15-04-08

and in the dependencies I have storybook: '6.0.0-beta/2'

@shilman shilman closed this as completed Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants