Bug: [no-unnecessary-condition] Does not account for optional chaining on potentially-void
values
#6261
Closed
4 tasks done
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
bug
Something isn't working
good first issue
Good for newcomers
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=4.9.4&sourceType=module&code=DYUwLgBAbghgTgSxgI1BAvBARCgxliGAZwiLEQDsBzCAH2gHsEATAbgFgAoL2RFUAPwA6ANoAGALqsgA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tiacTJTIAhtEK0yHJgBNK+SpPRRE0aB2iRwYAL4gtQA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eFYDAruuGAL4g9A
Repro Code
ESLint Config
tsconfig
Expected Result
No problems
Actual Result
The third line reports an error -
Unnecessary optional chain on a non-nullish value.
Additional Info
Related to #5766. That PR did not extend to the optional chaining part of this rule.
This is caused by
typescript-eslint/packages/type-utils/src/predicates.ts
Line 28 in ccd45d4
void
, onlynull
andundefined
.The text was updated successfully, but these errors were encountered: