Skip to content

[no-unused-expressions] no-unused-expressions works not as expected with optional chaining and condition #1764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kkatsuba opened this issue Mar 18, 2020 · 1 comment · Fixed by #2194
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@kkatsuba
Copy link

kkatsuba commented Mar 18, 2020

Repro

{
  "rules": {
    "no-unused-expressions": 0,
    "@typescript-eslint/no-unused-expressions": [2, {
      "allowShortCircuit": true
    }]
  }
}
const expr: any = false;
const v: { [key: string]: any } = {};
v.somestaff?.callMe(); // Works fine 👍
expr && v.somestaff?.callMe(); // Problem 😭

Expected Result
No error for line

Actual Result
image

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 2.23.0
@typescript-eslint/parser 2.23.0
TypeScript 3.7.5
ESLint 6.8.0
node 11.15.0
npm 6.7.0
@kkatsuba kkatsuba added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Mar 18, 2020
@bradzacher bradzacher added bug Something isn't working and removed triage Waiting for team members to take a look labels Mar 18, 2020
@InsOpDe
Copy link

InsOpDe commented Mar 23, 2020

Similar here:

dispatch?.()

throws the same warning
Edit:
My mistake, works as intended

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants