Bug: [no-unnecessary-condition] does not report unnecessary default value during object destructuring #10082
Closed
4 tasks done
Labels
bug
Something isn't working
duplicate
This issue or pull request already exists
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
triage
Waiting for team members to take a look
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=5.5.2&fileType=.ts&code=GYVwdgxgLglg9mABAYTgWwA4IKZigCgG9Fg45EBeRARkQF8AuRY0uJsENAI2wCd6AlMwBQiRL2xQQvJKwDcwusKA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tiacTJTIAhtEK0yHJgBNK%2BSpPRRE0aB2iRwYAL4gtQA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false
Repro Code
ESLint Config
tsconfig
Expected Result
I would expect a lint error here form
no-unnecessary-condition
because the default value assignment can never be reached, given thatfoo
is mandatory in the objectActual Result
no error shown
Additional Info
The rule correctly reports an error when nullish coalesce is used instead:
The text was updated successfully, but these errors were encountered: