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

Possible regression on variables defined as props #2330

Closed
meriadec opened this issue Jun 25, 2019 · 1 comment
Closed

Possible regression on variables defined as props #2330

meriadec opened this issue Jun 25, 2019 · 1 comment
Assignees

Comments

@meriadec
Copy link

@meriadec meriadec commented Jun 25, 2019

Not sure it's the right place to open the issue because it's also kinda related to eslint-plugin-flowtype. After bisecting it seems that the react/prop-types rule has a regression introduced since #2301 when used with Flowtype.

example better than a long explanation:

// @flow

import React from "react";

const foo = {
  some: "data",
};

type Props = {
  derived: { [$Keys<typeof foo>]: string },
};

export function Bar(props: Props) {
  const { derived } = props;
  return <div className={derived.some}>foo</div>;
}

before #2301: No errors
after #2301:

15:34  error  'derived.some' is missing in props validation  react/prop-types

@golopot does it rings a bell on your side? Would totally understand if the issue is irrelevant and is not in the scope of eslint-plugin-react.

Have a good day

@ljharb ljharb added the flow label Jun 25, 2019
@golopot

This comment has been minimized.

Copy link
Contributor

@golopot golopot commented Jun 26, 2019

The problem seems to that this plugin do not recognize "indexer property" in flow types.

// This will pass
type Props = { a: { b: string } };

export function Bar(props: Props) {
  return <>{props.a.b}</>;
}

// This will warn
type Props = { a: { [string]: string } };

export function Bar(props: Props) {
  return <>{props.a.b}</>;
                    ~ // 'a.b' is missing in props validationeslint(react/prop-types)
}

@yannickcr yannickcr self-assigned this Jun 26, 2019
@yannickcr yannickcr closed this in bc67d42 Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.