eslint-plugin-flowtype
eslint-plugin-flowtype copied to clipboard
React.ComponentType<any> flagged as unused when used as a param type in a method.
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.
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 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?
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
.