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

Comments

@meriadec
Copy link

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
Copy link
Contributor

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants