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

Bug Repro: Unused PropTypes detects flow destructuring #977

Merged
merged 1 commit into from Dec 13, 2019

Conversation

dozoisch
Copy link
Contributor

@dozoisch dozoisch commented Nov 25, 2016

Hello! I figured I would open a PR instead of an issue to be able to show the two failing test cases.

The first, should pass because notTarget is used. But it fails with 'target' PropType is defined but prop is never used. It seems like it takes the destructuring as the props instead of the props: Props. Note that this is fine if instead of destructuring { target } I do a simple argument like infos (added a test case to show).

type Props = {notTarget: string};
class Hello extends React.Component {
  props: Props;
  onEvent({ target }: { target: Object }) {};
  //   onEvent(infos: { target: Object }) {}; passes
  render () {
    return <div>Hello {this.props.notTarget}</div>;
  }
}

And on the invalid side, I added a similar test case with two props, one unused, but it fails on the wrong prop.


This change is Reviewable

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

I've rebased, and these tests appear to now be passing, so it must have been fixed in the interim!

@ljharb ljharb merged commit 8df4943 into jsx-eslint:master Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants