Skip to content

Commit

Permalink
Props: Repro #9922
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed Feb 21, 2020
1 parent 518607c commit 1447c85
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
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

0 comments on commit 1447c85

Please sign in to comment.