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

Does not return types from imported modules #375

Closed
graup opened this issue Jul 19, 2021 · 5 comments
Closed

Does not return types from imported modules #375

graup opened this issue Jul 19, 2021 · 5 comments
Labels
stale There is no activity for a long time.

Comments

@graup
Copy link

graup commented Jul 19, 2021

(This issue wraps up the following issues: #113 #371, possibly others)

If your component's typing comes from an external module, it is currently not returned by react-docgen-typescript.

Example:

import { styled } from '@stitches/react';

const Button = styled('button', {
  backgroundColor: 'gainsboro',
  borderRadius: '9999px',
  fontSize: '13px',
  padding: '10px 15px',
  '&:hover': {
    backgroundColor: 'lightgray',
  },
});

export default Button;

Running parse on this file returns no results, even though Typescript absolutely knows the type of Button.

I think the fix is fairly easy. Just rewrite this code to not return null if there're no comments, and instead apply the defaultProps optionally. Doing this, the resulting component name is not optimal (it becomes the name of the type), but we could just use the variable name of the default import (Button), which is what #113 suggested.

This is a problem for users of Storybook (storybookjs/storybook#12185)

@graup
Copy link
Author

graup commented Jul 20, 2021

I noticed that this works when you do export default Button as typeof Button which is a weird workaround.

@KL13NT
Copy link

KL13NT commented Jul 29, 2021

This is also true for the following:

import { COLOR_TYPES } from '@core/components/Icon/Icon';

export interface NavigationIconProps {
	/** Color of the icon */
	color?: COLOR_TYPES;
}

Where COLOR_TYPES is an exported type. RDT returns an empty array upon parsing this component.

@github-actions
Copy link

There was no activity for a long time. The issue will be closed soon.

@github-actions github-actions bot added the stale There is no activity for a long time. label Jan 25, 2022
@github-actions
Copy link

github-actions bot commented Feb 2, 2022

Closing this issue as obsolete.

@github-actions github-actions bot closed this as completed Feb 2, 2022
@EloB
Copy link

EloB commented Feb 8, 2022

This is also true for the following:

import { COLOR_TYPES } from '@core/components/Icon/Icon';

export interface NavigationIconProps {
	/** Color of the icon */
	color?: COLOR_TYPES;
}

Where COLOR_TYPES is an exported type. RDT returns an empty array upon parsing this component.

Did you find any solution to this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale There is no activity for a long time.
Projects
None yet
Development

No branches or pull requests

3 participants