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

Props: Repro #9922 #9924

Merged
merged 1 commit into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`react component properties 9922-ts-component-props 1`] = `
"import React from 'react';

const Button = ({
children,
onClick
}) => React.createElement(\\"button\\", {
onClick: onClick,
type: \\"button\\"
}, children);

const WrappedButton = ({
spacing,
...buttonProps
}) => React.createElement(\\"div\\", {
style: {
padding: spacing
}
}, React.createElement(Button, buttonProps));

export const component = WrappedButton;
WrappedButton.__docgenInfo = {
\\"description\\": \\"\\",
\\"methods\\": [],
\\"displayName\\": \\"WrappedButton\\",
\\"props\\": {
\\"spacing\\": {
\\"required\\": true,
\\"tsType\\": {
\\"name\\": \\"number\\"
},
\\"description\\": \\"\\"
}
}
};"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, { FunctionComponent, ComponentProps, HTMLAttributes } from 'react';

type Props = Pick<HTMLAttributes<HTMLButtonElement>, 'onClick'>;
const Button: FunctionComponent<Props> = ({ children, onClick }) => (
<button onClick={onClick} type="button">
{children}
</button>
);

type WrappedProps = {
spacing: number;
} & ComponentProps<typeof Button>;

const WrappedButton: FunctionComponent<WrappedProps> = ({
spacing,
...buttonProps
}: WrappedProps) => (
<div style={{ padding: spacing }}>
<Button {...buttonProps} />
</div>
);

export const component = WrappedButton;
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`react component properties 9922-ts-component-props 1`] = `
Object {
"rows": Array [
Object {
"defaultValue": null,
"description": "",
"name": "spacing",
"required": true,
"type": Object {
"detail": undefined,
"summary": "number",
},
},
],
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const fixtures = [
'9465-ts-type-props',
'8428-js-static-prop-types',
'9764-ts-extend-props',
'9922-ts-component-props',
];

const stories = storiesOf('Properties/React', module);
Expand Down