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

Typescript extended props not show v6 #12129

Open
Quadriphobs1 opened this issue Aug 19, 2020 · 40 comments
Open

Typescript extended props not show v6 #12129

Quadriphobs1 opened this issue Aug 19, 2020 · 40 comments

Comments

@Quadriphobs1
Copy link

Describe the bug
Define typescript props for component with extending other props, doesn't show the extended props.

For example a component with

interface TProps extends ComponentPropsWithoutRef<"input"> {
  label?: string;
  state?: InputState;
  helper?: string | React.ReactElement;
}

export const TextField = forwardRef(
  (
    { label, placeholder, state, helper, ...rest }: TProps,
    ref: Ref<HTMLInputElement>
  ) => (
    ...
  )
);

Produces the following

Screenshot 2020-08-19 at 10 55 40

Expected behavior
Its suppose to show all the props valid for the component such as type, max, min e.t.c

System:

Environment Info:
  Binaries:
    Node: 14.2.0 - ~/.nvm/versions/node/v14.2.0/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.7 - ~/.nvm/versions/node/v14.2.0/bin/npm
  Browsers:
    Chrome: 84.0.4147.125
    Firefox: 77.0.1
    Safari: 13.1.2
  npmPackages:
    @storybook/addon-docs: ^6.0.6 => 6.0.6 
    @storybook/addon-essentials: ^6.0.6 => 6.0.6 
    @storybook/addon-knobs: ^6.0.6 => 6.0.6 
    @storybook/addon-links: ^6.0.6 => 6.0.6 
    @storybook/addon-notes: ^5.3.19 => 5.3.19 
    @storybook/addon-storysource: ^6.0.6 => 6.0.6 
    @storybook/addon-viewport: ^6.0.6 => 6.0.6 
    @storybook/addons: ^6.0.6 => 6.0.6 
    @storybook/preset-create-react-app: ^3.1.4 => 3.1.4 
    @storybook/react: ^6.0.6 => 6.0.6
@petermikitsh
Copy link
Contributor

Try adding this to main.js:

  typescript: {
    reactDocgen: 'react-docgen-typescript',
    reactDocgenTypescriptOptions: {
      compilerOptions: {
        allowSyntheticDefaultImports: false,
        esModuleInterop: false,
      },
    }
  }

@shilman
Copy link
Member

shilman commented Aug 19, 2020

@petermikitsh should either of those options be made default?

@Quadriphobs1
Copy link
Author

Quadriphobs1 commented Aug 19, 2020

It seems like just having this works, so it must some misconfiguration internally

typescript: {
    reactDocgen: 'react-docgen-typescript',
    reactDocgenTypescriptOptions: {
    }
  }

@stale
Copy link

stale bot commented Sep 20, 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 Sep 20, 2020
@shilman
Copy link
Member

shilman commented Sep 22, 2020

These are the defaults. It's probably because it's excluding node_modules by default:

https://github.com/storybookjs/storybook/blob/next/lib/core/src/server/config/defaults.js#L4-L8

I think excluding node_modules is the right default, at least until we have something like #9110

Perhaps we need to make it easier to enable that, as a flag? Or just improve the documentation? What do you think?

@awkale
Copy link

awkale commented Oct 1, 2020

Try adding this to main.js:

  typescript: {
    reactDocgen: 'react-docgen-typescript',
    reactDocgenTypescriptOptions: {
      compilerOptions: {
        allowSyntheticDefaultImports: false,
        esModuleInterop: false,
      },
    }
  }

Does the above go inside of
module.exports = {}

I don't see any props that have been extended.

@shilman
Copy link
Member

shilman commented Oct 2, 2020

@awkale yes

@jonniebigodes
Copy link
Contributor

A recent pull request #12841 was created to adjust the documentation and include a bit more of context regarding the issue.

Let me know if you're ok with it and any additional feedback is welcome.

Stay safe

shilman added a commit that referenced this issue Oct 21, 2020
Chore: update documentation to address issue #12129
shilman added a commit that referenced this issue Oct 22, 2020
Chore: update documentation to address issue #12129
@stale
Copy link

stale bot commented Dec 25, 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 Dec 25, 2020
@sidneypp
Copy link

I'm having the same problem right now, using the material ui, is anyone working on it?

@stale stale bot removed the inactive label Mar 13, 2021
@natac13
Copy link

natac13 commented Mar 23, 2021

Try adding this to main.js:

  typescript: {
    reactDocgen: 'react-docgen-typescript',
    reactDocgenTypescriptOptions: {
      compilerOptions: {
        allowSyntheticDefaultImports: false,
        esModuleInterop: false,
      },
    }
  }

This suggest is working for me, however it exposes every HTML prop as well, making the storybook ui unusable since each component now has close to 300 props.
Is there a way to stop the extending at the MUI package and no further??

@shilman
Copy link
Member

shilman commented Mar 23, 2021

@natac13 the propFilter config option is a function, so you should be able to do something tricky there to get only the props you want

@ptoly
Copy link

ptoly commented May 4, 2021

I attempted to get the props using the propFilter but still doesn't work.

propFilter: (prop) => {
        return prop.parent
            ? /@material-ui/.test(prop.parent.fileName) ||
            !/node_modules/.test(prop.parent.fileName)
            : true;
      },

@andresdsep
Copy link

It seems like just having this works, so it must some misconfiguration internally

typescript: {
    reactDocgen: 'react-docgen-typescript',
    reactDocgenTypescriptOptions: {
    }
  }

Personally, it only seemed to work for me with this configuration. Having the additional two booleans in there would break it. Unfortunately, having this new config brings in the props I wanted, but it wrecks some other controls I have (such as limiting another prop to a couple of options).

@KasimAhmic
Copy link

Currently we're using Storybook 6.2.9 with Material UI 4.12.0 and the below configuration works flawlessly for us. It renders all the MUI props properly and ignores all the default HTML props. The two key changes for us were the propFilter and allowSyntheticDefaultImports options. Hope this helps some of you!

module.exports = {
  stories: ["../src/**/*.stories.@(ts|tsx|js|jsx)"],
  addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
  typescript: {
    check: true,
    reactDocgen: "react-docgen-typescript",
    reactDocgenTypescriptOptions: {
      shouldExtractLiteralValuesFromEnum: true,
      propFilter: (prop) =>
        prop.parent
          ? /@material-ui/.test(prop.parent.fileName) || !/node_modules/.test(prop.parent.fileName)
          : true,
      compilerOptions: {
        allowSyntheticDefaultImports: false,
      },
    },
  },
}

@mstosio
Copy link

mstosio commented Sep 3, 2021

None of those works for me, some props are extended and created correctly. For example for Button, but for a lot of components I'm getting some useless garbage and not correct props for example Alert. Any solution for this?

@mstosio
Copy link

mstosio commented Sep 17, 2021

Maybe it a little bit tricky but I found temporary solution to generate only material ui props and ignore all of HTML props.

module.exports = {
  stories: ["../src/**/*.stories.tsx"],
  // Add any Storybook addons you want here: https://storybook.js.org/addons/
  addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
  typescript: {
    check: false,
    checkOptions: {},
    reactDocgen: "react-docgen-typescript",
    reactDocgenTypescriptOptions: {
      shouldExtractLiteralValuesFromEnum: true,
      propFilter: (prop) => {
        return prop.parent
            ?  prop.parent.name !== 'DOMAttributes' && prop.parent.name !== 'HTMLAttributes' && prop.parent.name !== 'AriaAttributes'
            : true;
      },
    },
  },
}

@lucasluca
Copy link

Having the same problem here

@bastiW
Copy link

bastiW commented Nov 29, 2021

@mstosio

How does your button story look like?

I tried with your example and the following story.

But the args table is still not generated (it works for non mui components)

import React from 'react';
import {ComponentStory, ComponentMeta } from '@storybook/react';

import {Button} from "@mui/material";

export default {
  title: 'Components/Button',
  component: Button,
  argTypes: {
    variant: {
      options: ['contained', 'outlined'],
      control: { type: 'radio' },
    },
  },
} as ComponentMeta<typeof Button>;

const Template: ComponentStory<typeof Button> = (args) => <Button {...args} >My Button</Button>;

export const PrimaryButton = Template.bind({});
PrimaryButton.args = {
  variant: 'outlined'
};


@dirkvanvugt
Copy link

The configuration from @mstosio works for me.

I however also need to create named exports for mui components instead of a default export (this is mentioned on the Storybook TypeScript docs as well).

So I create a file

import Button, { ButtonProps } from '@mui/material/Button';

export const MyButton = ({ ...props }: ButtonProps) => <Button {...props} />;

And then import the MyButton in the story. I'm using the same setup as @bastiW for writing stories. Now I get the correct props displayed in the Docs tab.

I hope this helps.

@mstosio
Copy link

mstosio commented Dec 2, 2021

@mstosio

How does your button story look like?

I tried with your example and the following story.

But the args table is still not generated (it works for non mui components)

import React from 'react';
import {ComponentStory, ComponentMeta } from '@storybook/react';

import {Button} from "@mui/material";

export default {
  title: 'Components/Button',
  component: Button,
  argTypes: {
    variant: {
      options: ['contained', 'outlined'],
      control: { type: 'radio' },
    },
  },
} as ComponentMeta<typeof Button>;

const Template: ComponentStory<typeof Button> = (args) => <Button {...args} >My Button</Button>;

export const PrimaryButton = Template.bind({});
PrimaryButton.args = {
  variant: 'outlined'
};
import Button from './Button'
import { LoadingButtonProps as ButtonProps } from '@mui/lab';
import { Story, Meta } from '@storybook/react';

export default {
    component: Button,
    title: 'Inputs/Button',
} as Meta;

const Template: Story<ButtonProps> = (args: ButtonProps) => <Button {...args} />;

export const PrimaryButton = Template.bind({});


PrimaryButton.args = {
    children: 'Button',
    variant: 'contained',
    color: 'primary',
};

Try to import ButtonProps from Material UI. I think you are missing this part.

@stale
Copy link

stale bot commented Jan 9, 2022

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 Jan 9, 2022
@krishnans
Copy link

did anyone tried this in Mui 5. I have added additional properties in theme like below

declare module '@mui/material/styles' {

    interface TypographyVariants {
      body14: React.CSSProperties;
      body14b: React.CSSProperties;
    }
 
    // allow configuration using `createTheme`
    interface TypographyVariantsOptions {
      body14?: React.CSSProperties;
      body14b?: React.CSSProperties;
    }
  }
  
  // Update the Typography's variant prop options
  declare module '@mui/material/Typography' {
    interface TypographyPropsVariantOverrides {
      body14: true;
      body14b: true;
    }
  } 

I can see and use the additional variants through the code, but not in storybook

I am using
Node: 14.7.0
npm: 8.0.0
yarn: 1.21.1

React: 17
storybook: 6.5.0-alpha

@stale stale bot removed the inactive label Apr 26, 2022
@VietNguyenR
Copy link

Maybe it a little bit tricky but I found temporary solution to generate only material ui props and ignore all of HTML props.

module.exports = {
  stories: ["../src/**/*.stories.tsx"],
  // Add any Storybook addons you want here: https://storybook.js.org/addons/
  addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
  typescript: {
    check: false,
    checkOptions: {},
    reactDocgen: "react-docgen-typescript",
    reactDocgenTypescriptOptions: {
      shouldExtractLiteralValuesFromEnum: true,
      propFilter: (prop) => {
        return prop.parent
            ?  prop.parent.name !== 'DOMAttributes' && prop.parent.name !== 'HTMLAttributes' && prop.parent.name !== 'AriaAttributes'
            : true;
      },
    },
  },
}

Nice one and works fine, thanks a lot. Do we have an official solution now?

@ivanbanov
Copy link

Even though the code forces savePropValueAsString: true


It didn't work out of the box for me and I needed to add it manually

module.exports = {
  typescript: {
    // https://github.com/storybookjs/storybook/issues/12129#issuecomment-921878013
    reactDocgen: "react-docgen-typescript",
    reactDocgenTypescriptOptions: {
      shouldExtractLiteralValuesFromEnum: true,
      savePropValueAsString: true, // <--- here
      propFilter: prop => true /* your filter */
    },
  },
}

@ivanbanov
Copy link

Oh actually it was shouldRemoveUndefinedFromOptional

@yarinsa
Copy link

yarinsa commented Nov 16, 2022

If anyone is looking for a solution working with ant-design & react-docgen-typescript. The following solves the issue:

  1. In the component level, redeclare the Props even if empty, "redeclare" the component so docgen can infer the propTypes (see example)
// Alert.tsx
import type { AlertProps as AntAlertProps } from 'antd/es/alert';
import AntAlert from 'antd/es/alert';

import { FC } from 'react';

export interface Props extends AntAlertProps {}

const Alert: FC<Props> = ({ ...props }: Props) => {
  return <AntAlert {...props} />;
};

export default Alert;
export type { Props as AlertProps };

  1. Add the following configuration to filter in antd props (node_modules is filtered out by default)
 reactDocgen: 'react-docgen-typescript',
    reactDocgenTypescriptOptions: {
      // By default react-doc-gen-typescript filters node_modules type, this includes antd types
      tsconfigPath: '../tsconfig.json',
      propFilter: (prop: any) => {
        const res = /antd/.test(prop.parent?.fileName) || !/node_modules/.test(prop.parent?.fileName);
        return prop.parent ? res : true;
      },
      // The following 2 options turns string types into string literals and allows
      shouldExtractLiteralValuesFromEnum: true,
      savePropValueAsString: true,
      shouldRemoveUndefinedFromOptional: true,
    },

@idanziv
Copy link

idanziv commented Feb 15, 2023

I am having a similar problem to @krishnans with my own extended MUI 5 Theme
I extended my Theme as instructed in the MUI docs and can use the custom color in the code but the dropdown control in Storybook doesn't show the color I added as a pickable value.

I extended my theme like this:

import '@mui/material/styles';
import '@mui/material/Button';

declare module '@mui/material/styles/createPalette' {
    interface Palette {
        myCustomColor: Palette['primary'];
    }
    interface PaletteOptions {
        myCustomColor?: PaletteOptions['primary'];
    }
}

declare module '@mui/material/Button/Button' {
    interface ButtonPropsColorOverrides {
        myCustomColor: true;
    }
}

My Storybook main.js file looks like this:

module.exports = {
  stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
  addons: [
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "@storybook/addon-interactions",
  ],
  framework: "@storybook/react",
  core: {
    builder: "@storybook/builder-webpack5",
  },
  typescript: {
    check: false,
    checkOptions: {},
    reactDocgen: "react-docgen-typescript",
    reactDocgenTypescriptOptions: {
      allowSyntheticDefaultImports: false, // speeds up storybook build time
      esModuleInterop: false, // speeds up storybook build time
      shouldExtractValuesFromUnion: true,
      shouldExtractLiteralValuesFromEnum: true, // makes union prop types like variant and size appear as select controls
      shouldRemoveUndefinedFromOptional: true, // makes string and boolean types that can be undefined appear as inputs and switches
      savePropValueAsString: true,
      propFilter: (prop) =>
        prop.parent ? !/node_modules/.test(prop.parent.fileName) : true,
      skipPropsWithoutDoc: false,
      skipChildrenPropWithoutDoc: false,
      tsconfigPath: '../tsconfig.json',
    },
  },
};

And my Button.tsx component file looks like this:

import * as React from "react";
import { Button as MaterialButton } from "@mui/material";
import type { ButtonProps as MuiButtonProps } from "@mui/material";

export interface ButtonProps extends MuiButtonProps {
  label: string;
  onClick: React.MouseEventHandler<HTMLButtonElement>;
}

export const Button: React.FC<ButtonProps> = (props: ButtonProps) => {
  const { label } = props;
  return <MaterialButton {...props}>{label}</MaterialButton>;
};

With this result, where myCustomColor is not shown in the color dropdown options:
image

I am using:
node: 18.14.0
npm: 9.3.1
react: 18.2.0
typescript: 4.9.5
@storybook/react: 6.5.16

@shubham799
Copy link

shubham799 commented Mar 27, 2023

Any luck? i am still not getting all MUI props in storybook UI.

@idanziv
Copy link

idanziv commented Mar 28, 2023

@shubham799 I kinda worked around this by using SB argTypes and defining the needed props and possible values explicitly.
It's not the best but seeing as there's no update yet it worked for our usecase.

Referring to the color problem above, this is how we solved it:

// colors.ts
import { theme } from './theme';

const muiNonColorValues = [
  'mode',
  'common',
  'grey', // this is not a color even though it has the name of one :shrug:
  'contrastThreshold',
  'getContrastText',
  'augmentColor',
  'tonalOffset',
  'text',
  'divider',
  'background',
  'action',
];

export const colors = Object.keys(theme.palette).filter(
  (colorKey) => !muiNonColorValues.includes(colorKey),
);
// Button.stories.tsx

import type { ComponentStory, ComponentMeta } from '@storybook/react';

import { Button } from './Button';
import { colors } from '../../styles/colors';

export default {
  /* 👇 The title prop is optional.
   * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
   * to learn how to generate automatic titles
   */
  title: 'Button',
  component: Button,
  argTypes: {
    color: {
      options: colors,
      control: 'select',
      description:
        'The color of the component. It supports both default MUI colors and custom colors defined in our Theme',
      table: {
        type: null,
      },
    },
  },
} as ComponentMeta<typeof Button>;

// ...our stories

@CHE1RON
Copy link

CHE1RON commented Apr 24, 2023

This still happens and since there's no way determining the cause, this is rather frustrating. I checked with all configurations shown above, and nothing works as expected (1) props are shown, 2) with their correct control types and 3) possible values) - since MUI is (by far) the largest React component library, this is something really worth being investigated / documented, because the docs don't work 😭

@kylegach
Copy link
Contributor

kylegach commented May 3, 2023

@integrayshaun — Mind looking into this? It appears the MUI recipe doesn't work for all setups?

If someone here can provide a simplified reproduction (https://storybook.new is great for this), that would be a big help. Thanks!

@ShaunEvening
Copy link
Contributor

Hey folks, here's an updated example repo for the material UI recipe to help you on your way.

If you have more questions, let me know and i'll work on making it clearer

https://stackblitz.com/edit/github-ju9knk?file=.storybook/preview.ts

@kylegach kylegach removed this from Learning Team May 8, 2023
@d9k
Copy link

d9k commented May 21, 2023

My propFilter declaration:

    reactDocgenTypescriptOptions: {
      shouldExtractLiteralValuesFromEnum: true,
      propFilter: (prop) => {
        if (!prop.parent?.name) {
          return true;
        }

        if (['value', 'onChange'].includes(prop.name)) {
          return true;
        }

        if ([
          'AriaAttributes',
          'AnchorHTMLAttributes',
          'Attributes',
          'ButtonHTMLAttributes',
          'ClassAttributes',
          'DOMAttributes',
          'HTMLAttributes',
          'InputHTMLAttributes'
        ].includes(prop.parent.name)) {
          return false;
        }

        if (/node_modules\/typescript/.test(prop.parent.fileName)) {
          return false;
        }

        //if (/node_modules/.test(prop.parent.fileName)) {
        //  console.log('__TEST__', prop.parent.name);
        //  console.log('__TEST__2__', prop);
        //}

        return true;
      },
    },

@lucianobarauna
Copy link

@yarinsa thanks for solution

@developerdanwu
Copy link

I am having a similar problem to @krishnans with my own extended MUI 5 Theme I extended my Theme as instructed in the MUI docs and can use the custom color in the code but the dropdown control in Storybook doesn't show the color I added as a pickable value.

I extended my theme like this:

import '@mui/material/styles';
import '@mui/material/Button';

declare module '@mui/material/styles/createPalette' {
    interface Palette {
        myCustomColor: Palette['primary'];
    }
    interface PaletteOptions {
        myCustomColor?: PaletteOptions['primary'];
    }
}

declare module '@mui/material/Button/Button' {
    interface ButtonPropsColorOverrides {
        myCustomColor: true;
    }
}

My Storybook main.js file looks like this:

module.exports = {
  stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
  addons: [
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "@storybook/addon-interactions",
  ],
  framework: "@storybook/react",
  core: {
    builder: "@storybook/builder-webpack5",
  },
  typescript: {
    check: false,
    checkOptions: {},
    reactDocgen: "react-docgen-typescript",
    reactDocgenTypescriptOptions: {
      allowSyntheticDefaultImports: false, // speeds up storybook build time
      esModuleInterop: false, // speeds up storybook build time
      shouldExtractValuesFromUnion: true,
      shouldExtractLiteralValuesFromEnum: true, // makes union prop types like variant and size appear as select controls
      shouldRemoveUndefinedFromOptional: true, // makes string and boolean types that can be undefined appear as inputs and switches
      savePropValueAsString: true,
      propFilter: (prop) =>
        prop.parent ? !/node_modules/.test(prop.parent.fileName) : true,
      skipPropsWithoutDoc: false,
      skipChildrenPropWithoutDoc: false,
      tsconfigPath: '../tsconfig.json',
    },
  },
};

And my Button.tsx component file looks like this:

import * as React from "react";
import { Button as MaterialButton } from "@mui/material";
import type { ButtonProps as MuiButtonProps } from "@mui/material";

export interface ButtonProps extends MuiButtonProps {
  label: string;
  onClick: React.MouseEventHandler<HTMLButtonElement>;
}

export const Button: React.FC<ButtonProps> = (props: ButtonProps) => {
  const { label } = props;
  return <MaterialButton {...props}>{label}</MaterialButton>;
};

With this result, where myCustomColor is not shown in the color dropdown options: image

I am using: node: 18.14.0 npm: 9.3.1 react: 18.2.0 typescript: 4.9.5 @storybook/react: 6.5.16

I tried using this and it works for module augmentation. The key is the include option below. My declaration file is named styles.d.ts. You have to include it for storybook to take into account the augmented styles. Hope it helps someone

const config: StorybookConfig = {
  typescript: {
    check: false,
    reactDocgen: 'react-docgen-typescript',
    reactDocgenTypescriptOptions: {
      include: ['**/**.tsx', 'src/themes/styles.d.ts'],
      shouldExtractLiteralValuesFromEnum: true,
      skipChildrenPropWithoutDoc: false,
      shouldRemoveUndefinedFromOptional: true,
      tsconfigPath: './tsconfig.json',
      compilerOptions: {
        allowSyntheticDefaultImports: false,
        esModuleInterop: false,
      },
      propFilter: (prop) =>
        prop.parent
          ? /@material-ui/.test(prop.parent.fileName) ||
            !/node_modules/.test(prop.parent.fileName)
          : true,
    },
  },
...
};

@CHE1RON
Copy link

CHE1RON commented Jan 3, 2024

I'm still struggling to get it working with @mantine packages .. any ideas, guys? 🙏

@ShaunEvening
Copy link
Contributor

@CHE1RON,

Can you provide me a repro with @mantine for investigation?

@adirzoari
Copy link

reactDocgen: "react-docgen-typescript",
reactDocgenTypescriptOptions: {
shouldExtractLiteralValuesFromEnum: true,
propFilter: (prop) => {
return prop.parent
? prop.parent.name !== 'DOMAttributes' && prop.parent.name !== 'HTMLAttributes' && prop.parent.name !== 'AriaAttributes'
: true;
},
},

Screenshot 2024-03-08 at 1 19 39

},

Screenshot 2024-03-08 at 1 19 55 Screenshot 2024-03-08 at 1 20 29

mstosio

@mstosio thanks. It helps me, but it adds an undefined value each time. Is there a solution to prevent this undefined value?
@developerdanwu @ivanbanov @andresdsep @Quadriphobs1 @dirkvanvugt

@developerdanwu
Copy link

reactDocgen: "react-docgen-typescript",
reactDocgenTypescriptOptions: {
shouldExtractLiteralValuesFromEnum: true,
propFilter: (prop) => {
return prop.parent
? prop.parent.name !== 'DOMAttributes' && prop.parent.name !== 'HTMLAttributes' && prop.parent.name !== 'AriaAttributes'
: true;
},
},

Screenshot 2024-03-08 at 1 19 39 > },

Screenshot 2024-03-08 at 1 19 55 Screenshot 2024-03-08 at 1 20 29

mstosio

@mstosio thanks. It helps me, but it adds an undefined value each time. Is there a solution to prevent this undefined value? @developerdanwu @ivanbanov @andresdsep @Quadriphobs1 @dirkvanvugt

@adirzoari try add shouldRemoveUndefinedFromOptional: true to ur config

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