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

generated-flow-types doesn't report invalid imports #59

Open
mrtnzlml opened this issue May 17, 2019 · 0 comments
Open

generated-flow-types doesn't report invalid imports #59

mrtnzlml opened this issue May 17, 2019 · 0 comments

Comments

@mrtnzlml
Copy link

Hello, my colleague discovered that incorrect Relay imports are not reported as expected. Failing test (well, should be failing but it's not):

{
  code: `
    import type {invalid as MyComponent_user} from './__generated__/MyComponent_user.graphql'
    class MyComponent extends React.Component<{user: MyComponent_user}> {
      render() {
        return <div />;
      }
    }

    createFragmentContainer(MyComponent, {
      user: graphql\`fragment MyComponent_user on User {id}\`,
    });
  `,
  errors: [
    {
      message: 'TODO: invalid type imported'
    }
  ]
},

Notice that the imported type invalid as MyComponent_user doesn't exist. In fact, this rule doesn't require the import at all and it is happy even if you delete the import type line completely. Seems like it takes into account only the property name used in props definition but not the imports. I believe this is not intended and it's a bug because seems like there are tests to cover this but they don't work as I would expect - the import is irrelevant for them:

import type {MyComponent_user} from './__generated__/MyComponent_user.graphql'
class MyComponent extends React.Component<{user: MyComponent_user}> {

cc @kassens, thanks for checking it and confirming/rejecting it

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

1 participant