Closed
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
Repro Code
declare const foo: string | null;
foo && foo.toString();
ESLint Config
module.exports = {
"rules": {
"@typescript-eslint/prefer-optional-chain": [
"error",
{
"requireNullish": true
}
]
}
}
tsconfig
Expected Result
I believe that this case should be reported. (see Additional Info below)
Actual Result
This case isn't reported.
Additional Info
I noticed this while working on #8382: there is an example of incorrect code with requireNullish: true
- https://typescript-eslint.io/rules/prefer-optional-chain#requirenullish. But it doesn't actually contain any lint errors.
As I understand it, requireNullish
just restricts the set of types of the left operand of a logical expression to types that are nullish. If we disable requireNullish
, then the rule reports on the code provided above (playground).
Therefore, I believe that this case should be reported.