Describe the bug
When using React with TypeScript, component stories fetch props from interfaces when provided to function component arguments. But not all props of the interface are seen in the story docs. When you import an interface from a node module, in this case @material-ui, you will not see those props. You can only see the props of interfaces that you declared in that components file.
To Reproduce
- Create a React function component.
- Give an interface, which either extends an interface imported from a module or is combined with one via &, to that components prop type.
- Create a story for that component.
- You will not see the imported props in the docs tab of that story.
Expected behavior
I expected to see props from the interface I imported and props of the interface in which I extended that earlier imported interface.
Screenshots
https://imgur.com/a/XSgiPh0
Code snippets
Alert/index.tsx
import MuiAlert, {AlertProps as MUIAlertProps} from "@material-ui/lab/Alert";
import {makeStyles} from "@material-ui/core/styles";
function CustomAlert(props) {
return <MuiAlert elevation={6} {...props} />;
}
const useStyles = makeStyles((theme) => ({
root: {
width: "100%",
marginBottom: theme.spacing(2),
"& > * + *": {
marginTop: theme.spacing(2),
},
},
}));
export interface AlertProps extends MUIAlertProps {
message: string;
lol: string;
}
const Alert = ({message, severity, variant, className, ...otherProps}: AlertProps) => {
const classes = useStyles();
return (
<div className={classes.root}>
{/* eslint-disable-next-line react/no-children-prop */}
<CustomAlert
className={className}
severity={severity}
variant={variant}
{...otherProps}
children={message}
/>
</div>
);
};
Alert.defaultProps = {
severity: "success",
message: "Please provide a message",
variant: "filled",
};
export default Alert;
Alert.stories.js
import Alert from "../components/Alert";
export default {
title: "UI Elements/Alert",
component: Alert,
argTypes: {
variant: {
control: {
type: "select",
options: ["filled", "outlined"],
},
},
},
};
const Template: any = (args) => <Alert {...args} />;
export const Success: any = Template.bind({});
System
Environment Info:
System:
OS: Windows 10 10.0.19041
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Binaries:
Node: 12.18.3 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.4 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.14.6 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 87.0.4280.141
Edge: Spartan (44.19041.423.0), Chromium (87.0.664.75)
Additional context
None
Describe the bug
When using React with TypeScript, component stories fetch props from interfaces when provided to function component arguments. But not all props of the interface are seen in the story docs. When you import an interface from a node module, in this case @material-ui, you will not see those props. You can only see the props of interfaces that you declared in that components file.
To Reproduce
Expected behavior
I expected to see props from the interface I imported and props of the interface in which I extended that earlier imported interface.
Screenshots
https://imgur.com/a/XSgiPh0
Code snippets
Alert/index.tsx
Alert.stories.js
System
Environment Info:
System:
OS: Windows 10 10.0.19041
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Binaries:
Node: 12.18.3 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.4 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.14.6 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 87.0.4280.141
Edge: Spartan (44.19041.423.0), Chromium (87.0.664.75)
Additional context
None