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

Version 7.25.2 missing prop-types with typescript parametrised props #3074

Closed
anajavi opened this issue Sep 17, 2021 · 4 comments · Fixed by #3076
Closed

Version 7.25.2 missing prop-types with typescript parametrised props #3074

anajavi opened this issue Sep 17, 2021 · 4 comments · Fixed by #3076

Comments

@anajavi
Copy link

anajavi commented Sep 17, 2021

The following works alright in 7.25.1:

type Props<ValueType> = {
  value: ValueType;
  onClick: (value: ValueType) => void;
};

// prettier-ignore
const Button = <T,>({ onClick, value }: Props<T>) => {
  return <button onClick={() => onClick(value)}>BUTTON</button>;
};

const valueObj = {
  aprop: 'avalue'
};

export default function App() {
  return (
    <div className="App">
      <h1>a button</h1>
      <Button onClick={(value) => console.log(value)} value={valueObj} />
    </div>
  );
}

With version 7.25.2 same code results in react/prop-types errors

7:23  error  'onClick' is missing in props validation  react/prop-types
7:32  error  'value' is missing in props validation    react/prop-types
@ljharb
Copy link
Member

ljharb commented Sep 17, 2021

Seems like maybe #3064 caused this regression; cc @vedadeepta?

@vedadeepta
Copy link
Contributor

vedadeepta commented Sep 17, 2021

Yeah, will investigate tomorrow. There seems to be just too many edge cases for generic types. Thanks for letting me know.

Update: not a edge case upon investigating.

@davidcalhoun
Copy link

davidcalhoun commented Sep 17, 2021

Can confirm this is happening with a similar setup here. Locking down to the previous version by adding this temporary Yarn resolution to package.json is a temporary workaround (note that you need to run yarn again after adding this):

{
...
    "resolutions": {
        "eslint-plugin-react": "7.25.1"
    }
...
}

@jukbot
Copy link

jukbot commented Sep 18, 2021

Confirmed this issue, got 'props validation error' even using InferGetStaticPropsType<T> in NextJS. I've to roll back to the 7.25.1 workaround temporarily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants