react-styleguidist icon indicating copy to clipboard operation
react-styleguidist copied to clipboard

@component comment + Flow types give "unknown" property type

Open FezVrasta opened this issue 6 years ago â€ĸ 25 comments
trafficstars

Current behavior

If you define a component using Emotion (or any styled components lib I guess) like the following:

// @flow
import React from 'react';
import styled from '@emotion/styled';

type Props = {
	color: string,
};

const Button = styled(({ color, ...props }: Props) => <button {...props} />)`
	color: ${props => props.color};
`;

Button.defaultProps = {
	color: 'red',
};

// @component
export default Button;

The generated "props & methods" list will mark all the property types as "unknown":

image

To reproduce

https://github.com/FezVrasta/styleguidist-emotion-bug-repro/

Expected behavior

The Type should return a correct type, the same that happens if you do this:

// @flow
import React from 'react';
import styled from '@emotion/styled';

type Props = {
	color: string,
};

const Button = (props: Props) => <div />;

// @component
export default Button;

image

FezVrasta avatar Dec 13 '18 12:12 FezVrasta

😴 This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week without any further activity. Consider opening a pull request if you still have this issue or want this feature.

stale[bot] avatar Mar 13 '19 12:03 stale[bot]

Still valid, very valid.

FezVrasta avatar Mar 13 '19 13:03 FezVrasta

@FezVrasta Did you found what exactly the issue is ?

tata81 avatar Apr 29 '19 14:04 tata81

No, I'm sorry. 😞

FezVrasta avatar Apr 29 '19 14:04 FezVrasta

😴 This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week without any further activity. Consider opening a pull request if you still have this issue or want this feature.

stale[bot] avatar Jul 29 '19 03:07 stale[bot]

Hi, @FezVrasta I made it working by making another component and wrapping the styled-components around my original component. `// @flow import React from 'react'; import styled from '@emotion/styled';

type Props = { color: string, };

const StyledButton= styled(({color, ...props}: Props) => color: ${props => props.color};)

const Button = ()=> <StyledButton></StyledButton>

Button.defaultProps = { color: 'red', };

// @component export default Button;`

tata81 avatar Jul 29 '19 04:07 tata81

Thank you but that's not a viable solution, it's merely a workaround â˜šī¸

FezVrasta avatar Jul 29 '19 18:07 FezVrasta

😴 This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week without any further activity. Consider opening a pull request if you still have this issue or want this feature.

stale[bot] avatar Oct 27 '19 18:10 stale[bot]

Bump

FezVrasta avatar Oct 27 '19 19:10 FezVrasta

😴 This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week without any further activity. Consider opening a pull request if you still have this issue or want this feature.

stale[bot] avatar Jan 25 '20 20:01 stale[bot]

Bubububump - bu - bu - buu - buuuump

FezVrasta avatar Jan 25 '20 20:01 FezVrasta

😴 This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week without any further activity. Consider opening a pull request if you still have this issue or want this feature.

stale[bot] avatar Apr 25 '20 04:04 stale[bot]

Buuumpp pmuuuuB

FezVrasta avatar Apr 25 '20 05:04 FezVrasta

😴 This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week without any further activity. Consider opening a pull request if you still have this issue or want this feature.

stale[bot] avatar Jul 25 '20 04:07 stale[bot]

....

FezVrasta avatar Jul 26 '20 05:07 FezVrasta

😴 This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week without any further activity. Consider opening a pull request if you still have this issue or want this feature.

stale[bot] avatar Oct 24 '20 08:10 stale[bot]

Don't close this issue. This is an automatic message by Fresh - a bot against stale bots.

FezVrasta avatar Oct 25 '20 01:10 FezVrasta

😴 This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week without any further activity. Consider opening a pull request if you still have this issue or want this feature.

stale[bot] avatar Jan 23 '21 22:01 stale[bot]

Don't close this issue. This is an automatic message by Fresh - a bot against stale bots.

FezVrasta avatar Jan 24 '21 02:01 FezVrasta

😴 This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week without any further activity. Consider opening a pull request if you still have this issue or want this feature.

stale[bot] avatar Jun 11 '21 01:06 stale[bot]

Don't close this issue. This is an automatic message by Fresh - a bot against stale bots.

FezVrasta avatar Jun 11 '21 02:06 FezVrasta

😴 This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week without any further activity. Consider opening a pull request if you still have this issue or want this feature.

stale[bot] avatar Oct 02 '21 02:10 stale[bot]

Don't close this issue. This is an automatic message by Fresh - a bot against stale bots.

FezVrasta avatar Oct 03 '21 02:10 FezVrasta

😴 This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week without any further activity. Consider opening a pull request if you still have this issue or want this feature.

stale[bot] avatar Apr 16 '22 06:04 stale[bot]

Don't close this issue. This is an automatic message by Fresh - a bot against stale bots.

FezVrasta avatar Apr 17 '22 02:04 FezVrasta