mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-19 05:02:40 +08:00
Addon-docs: Remove undefined from optional values in Typescript Props
This commit is contained in:
parent
8ab8425ec5
commit
7b922e4e0a
14
examples/official-storybook/components/OptionalButton.tsx
Normal file
14
examples/official-storybook/components/OptionalButton.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import React from 'react';
|
||||
|
||||
// Repro #11019
|
||||
interface Props {
|
||||
kind?: 'a' | 'b';
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export const OptionalButton = ({ disabled = false, kind = 'a' }: Props) => (
|
||||
// eslint-disable-next-line react/button-has-type
|
||||
<button {...{ disabled }}>Repro</button>
|
||||
);
|
||||
|
||||
export default OptionalButton;
|
@ -4,6 +4,7 @@ import { DocgenButton } from '../../components/DocgenButton';
|
||||
import { ButtonGroup, SubGroup } from '../../components/ButtonGroup';
|
||||
import { ForwardRefButton } from '../../components/ForwardRefButton';
|
||||
import { MemoButton } from '../../components/MemoButton';
|
||||
import { OptionalButton } from '../../components/OptionalButton';
|
||||
|
||||
<Meta
|
||||
title="Addons/Docs/props"
|
||||
@ -160,3 +161,7 @@ export const Template = (args = {}) => (
|
||||
## Component
|
||||
|
||||
<Props of={DocgenButton} />
|
||||
|
||||
## OptionalButton
|
||||
|
||||
<Props of={OptionalButton} />
|
||||
|
@ -3,6 +3,7 @@ export const typeScriptDefaults = {
|
||||
reactDocgen: 'react-docgen-typescript',
|
||||
reactDocgenTypescriptOptions: {
|
||||
shouldExtractLiteralValuesFromEnum: true,
|
||||
shouldRemoveUndefinedFromOptional: true,
|
||||
propFilter: (prop) => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true),
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user