Bug: [prefer-optional-chain] doesn't report at all when requireNullish
is true
#8487
Closed
4 tasks done
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
bug
Something isn't working
locked due to age
Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=5.3.3&fileType=.ts&code=CYUwxgNghgTiAEYD2A7AzgF3gMyUgXPJjAJYoDm8APvCgK4QQDcAULkvAGSc54B0GJAGUMpCgAoAlEyA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Y6RAM0WloHsalfkwCG8WmQAWo5ujABtcNhy9o-aJAA0ylVhXYYiAI6xKnAHIJGyKfPxxEu7AF9nAXWVuXQA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false
Repro Code
ESLint Config
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 disablerequireNullish
, then the rule reports on the code provided above (playground).Therefore, I believe that this case should be reported.
The text was updated successfully, but these errors were encountered: