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

Fix generated flow type rule w readonly/aliased types #60

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 31 additions & 21 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,27 +402,6 @@ ruleTester.run('generated-flow-types', rules['generated-flow-types'], {
});
`
},
{
code: `
type RelayProps = {
user: MyComponent_user
}

type Props = {
other: ?Object,
} & RelayProps;

class MyComponent extends React.Component<Props> {
render() {
return <div />;
}
}

createFragmentContainer(MyComponent, {
user: graphql\`fragment MyComponent_user on User {id}\`,
});
`
}
]),
invalid: [
{
Expand Down Expand Up @@ -1346,6 +1325,37 @@ The prop passed to useFragment() should be typed with the type 'TestFragment_foo
column: 15
}
]
},
{
filename: 'MyComponent.jsx',
code: `
type RelayProps = {
user: MyComponent_user
}

type Props = {
other: ?Object,
} & RelayProps;

class MyComponent extends React.Component<Props> {
render() {
return <div />;
}
}

createFragmentContainer(MyComponent, {
user: graphql\`fragment MyComponent_user on User {id}\`,
});
`,
errors: [
{
message:
'`user` is not declared in the `props` of the React component or it is not marked with the generated flow type `MyComponent_user`. ' +
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @josephsavona! Could you please check this issue? #59 I think it's related to what you wrote here since seems like it doesn't work as expected (even though in this case it's probably fine).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks like a separate issue. The issue here is just that we’re not following type aliases and not unwrapping readonly. Happy to accept PRs for #59 though!

'See https://facebook.github.io/relay/docs/en/graphql-in-relay.html#importing-generated-definitions',
line: 10,
column: 15
}
]
}
]
});