This
{
"rules": {
"@typescript-eslint/no-unnecessary-condition": ["error", "ignoreRhs": true | false]
}
}
type Item = {
type : string
}
function fn (arr : Item[]) : string {
// eslint complains about the optional chain on the next line
if (arr[0]?.type === "foo") {
return 'FOO'
}
return 'BAR'
}
Expected Result
No lint because the array item might not exist.
Actual Result
Eslint error, even though there should not be one
Versions
| package |
version |
@typescript-eslint/eslint-plugin |
2.11.0 |
@typescript-eslint/parser |
2.12.0 |
TypeScript |
3.7.3 |
ESLint |
6.7.2 |
node |
12.13.1 |
npm |
6.12.1 |
This
{ "rules": { "@typescript-eslint/no-unnecessary-condition": ["error", "ignoreRhs": true | false] } }Expected Result
No lint because the array item might not exist.
Actual Result
Eslint error, even though there should not be one
Versions
@typescript-eslint/eslint-plugin2.11.0@typescript-eslint/parser2.12.0TypeScript3.7.3ESLint6.7.2node12.13.1npm6.12.1