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

React.ComponentType<any> flagged as unused when used as a param type in a method. #482

Open
kevinbarabash opened this issue Apr 27, 2021 · 3 comments
Labels

Comments

@kevinbarabash
Copy link

function renderTab(Tab: React.ComponentType<any>): null {
    return null;
}

class Foo extends React.Component<Props, State> {
    renderTab(Tab: React.ComponentType<any>): null {  // 'ComponentType' is not defined. eslint(no-undef)
        return null;
    }
}

eslint only complains about the use of ComponentType when used as a param type in a method, but functions are fine.

This is using 5.7.2 of eslint-plugin-flowtype.

@Brianzchen
Copy link
Contributor

I tested this on my local and I don't get the eslint error tried 5.7.0 and 5.7.2. But additionally this shouldn't be an issue with eslint-plugin-flowtype it's more likely an issue with eslint itself and how it parses flow annotations, you can see the rule error is from eslint(no-undef)

@kevinbarabash
Copy link
Author

@Brianzchen thanks for checking. I thought it might be an issue with flow-define-type since it's supposed to suppress no-undef when reporting type identifiers. I have "flowtype/define-flow-type": "warn", and parser: "@babel/eslint-parser", set in my .eslintrc.js. Maybe changing to a different parser would help. What parser were you using when you tested this?

@Brianzchen
Copy link
Contributor

I'm using the same, @babel/eslint-parser@7.13.14 to be exact. I have define-flow-type from recommended config. So not quite sure what the difference may be. But we only switched to @babel/eslint-parser recently, few weeks ago we were on babel-eslint@10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants