Skip to content
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

Error E0718 is not an actual error #1199

Closed
Danny-06 opened this issue Feb 7, 2024 · 5 comments
Closed

Error E0718 is not an actual error #1199

Danny-06 opened this issue Feb 7, 2024 · 5 comments
Assignees
Milestone

Comments

@Danny-06
Copy link

Danny-06 commented Feb 7, 2024

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?

@tomocrafter
Copy link

tomocrafter commented Feb 14, 2024

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.

@strager
Copy link
Collaborator

strager commented Feb 17, 2024

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 strager self-assigned this Feb 17, 2024
@strager strager added this to the 3.2 milestone Feb 17, 2024
@tomocrafter
Copy link

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

@strager
Copy link
Collaborator

strager commented Feb 24, 2024

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

Nah, my brain just wasn't working. 😄

@strager
Copy link
Collaborator

strager commented Mar 4, 2024

Fix released in version 3.2.0.

@strager strager closed this as completed Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants