eslint-plugin-flowtype icon indicating copy to clipboard operation
eslint-plugin-flowtype copied to clipboard

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

Open kevinbarabash opened this issue 3 years ago • 3 comments

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.

kevinbarabash avatar Apr 27 '21 22:04 kevinbarabash

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)

Brianzchen avatar Apr 30 '21 22:04 Brianzchen

@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?

kevinbarabash avatar Apr 30 '21 23:04 kevinbarabash

I'm using the same, @babel/[email protected] 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.

Brianzchen avatar May 01 '21 01:05 Brianzchen