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

Issues with parsing destructured import #44

Open
kandji-joe opened this issue Apr 27, 2022 · 1 comment
Open

Issues with parsing destructured import #44

kandji-joe opened this issue Apr 27, 2022 · 1 comment

Comments

@kandji-joe
Copy link

When using both the script and online tool, if I use a file with destructured prop-types the types that get generated are unknown.

For example:

import { bool, string } from 'prop-types'
...
Component.propTypes = { isDisabled: bool, name: string }

will generate

interface ComponentProps {
  isDisabled?: unknown;
  name?: unknown;
}
@mskelton
Copy link
Owner

Doing this would require more thorough scope analysis to determine what bool is since it could be like this:

const bool = PropTypes.string

Not saying that's likely, just that to do this properly would require properly checking the scope of variables passed down. If you'd like to take a stab at this feel free, but it's not something I've seen before so I'm not sure I'll end up taking this on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants