Closed
Description
Repro
{
"parser": "@typescript-eslint/parser",
"extends": [
"plugin:@typescript-eslint/recommended"
]
}
interface Foo {
bar: number;
}
export const isFoo = (x: any): x is Foo => {
if (typeof x.bar !== 'number') {
return false;
}
return true;
}
Expected Result
No lint issues.
Actual Result
5:26 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
Additional Info
An any
type should be allowed as a function parameter when writing a type predicate, as it is reasonable for the function to take an any
and narrow the type based on some condition inside the function. Typescript 3.7 is going to have type assertion functions, and those should probably also allow the any
type.
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
2.3.2 |
@typescript-eslint/parser |
2.3.2 |
TypeScript |
3.6.3 |
ESLint |
6.5.1 |
node |
12.11.0 |
npm |
6.11.3 |