quick-lint-js icon indicating copy to clipboard operation
quick-lint-js copied to clipboard

Error E0718 is not an actual error

Open Danny-06 opened this issue 1 year ago • 3 comments

The error as documented in the official docs https://quick-lint-js.com/errors/E0718/ implies that the following scenario should throw an error:

const bug = { milestone: null };
console.log(bug.milestone);               // null
console.log(bug.milestone?.name);         // undefined
console.log(bug.milestone?.name.trim());  // throws an error

But the actual output when running the code is:

const bug = { milestone: null };
console.log(bug.milestone);               // null
console.log(bug.milestone?.name);         // undefined
console.log(bug.milestone?.name.trim());  // undefined

Is there a good reason for this error to be listed or should be removed?

Danny-06 avatar Feb 07 '24 20:02 Danny-06

I faced exact same error and it should be removed imo. eslint's no-unnecessary-condition rule https://typescript-eslint.io/rules/no-unnecessary-condition/ enforces ?. to be . after ?. and It sounds reasonable since above code won't raise an error.

tomocrafter avatar Feb 14 '24 12:02 tomocrafter

Is there a good reason for this error to be listed or should be removed?

This diagnostic should be removed. In fact, it is removed in master (#1192). I will ship the fix in version 3.2.

strager avatar Feb 17 '24 23:02 strager

@strager Thank you! now I wonder why it is introduced first, like was it actually occurs the error?

tomocrafter avatar Feb 17 '24 23:02 tomocrafter

now I wonder why it is introduced first, like was it actually occurs the error?

Nah, my brain just wasn't working. 😄

strager avatar Feb 24 '24 16:02 strager

Fix released in version 3.2.0.

strager avatar Mar 04 '24 05:03 strager