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

Add React$Element faux-generic #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sdougbrown
Copy link

Using React$Element<*> provides additional safety, and it'd be nice if
this plugin would support it rather than having to any-stub for
children and go backwards.

The only thing that's holding me up is adding the test - I seem to be getting an undefined result. Not sure if that's because the fbjs lib with the React$Element definition isn't included?

 FAIL  src/__tests__/classes.test.js
  ● react-flow-props-to-prop-types › 24. React$Element

    TypeError: unknown: Property object of MemberExpression expected node to be of a type ["Expression"] but instead got undefined

The test should probably look something like...

    {
      title: 'React$Element',
      code: `
        class Foo extends React.Component {
          props: {
            a: React$Element<*>
          };
        }
      `,
      output: `
        import _PropTypes from "prop-types";
        class Foo extends React.Component {
          props: {
            a: React$Element<*>
          };
          static propTypes = {
            a: _PropTypes.element.isRequired
          };
        }
      `,
    },

Thanks for your work on this.

Using `React$Element<*>` provides additional safety, and it'd be nice if
this plugin would support it rather than having to `any`-stub for
`children` and go backwards.
@rosskevin
Copy link

In general it appears this plugin, like others, has no awareness of flow's built-in libdefs or locally installed libdefs (e.g. flow-typed). @thejameskyle is there a plan for this?

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

Successfully merging this pull request may close these issues.

2 participants