Skip to content

[Bug] Enable Plugin to Properly Acknowledge Props Provided Via React.FC #3045

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

Closed
ITenthusiasm opened this issue Aug 19, 2021 · 0 comments · Fixed by #3049
Closed

[Bug] Enable Plugin to Properly Acknowledge Props Provided Via React.FC #3045

ITenthusiasm opened this issue Aug 19, 2021 · 0 comments · Fixed by #3049

Comments

@ITenthusiasm
Copy link

Carryover from #2353, intended to remove the noise from the problem.

As stated in the opening comment of the original issue, this plugin does not properly validate props when React.FC is used. Information was provided at typescript-eslint/typescript-eslint#3075 on how to address this issue. The suggested approach just needs to be implemented.

cc: @ljharb

Original Opening Comment from @dchebakov

Tell us about your environment

  • ESLint Version: v6.0.1
  • Node Version: v10.16.0
  • npm Version: v6.9.0

Configuration

module.exports = {
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: './tsconfig.json',
  },
  plugins: ['@typescript-eslint'],
  extends: [
    'plugin:react/recommended',
    'plugin:@typescript-eslint/recommended',
  ],
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

import * as React from 'react';
interface PersonProps {
    username: string;
}
const Person: React.FunctionComponent<PersonProps> = (props): React.ReactElement => (
    <div>{props.username}</div>
);
npx eslint src --ext .tsx

What did you expect to happen?
eslint show no errors, because type definition actually present in generic type React.FunctionComponent<PersonProps>

What actually happened? Please include the actual, raw output from ESLint.

error    'username' is missing in props validation       react/prop-types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants