Closed
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have read the FAQ and my problem is not listed.
Description
Ref: #7955
IMO most codebases would prefer to avoid nullish coalescing in conditional tests.
Consider the downlevelled output:
if (x || y) { }
// vs
if (x ?? y) { }
// downlevelled to
if (x != null ? x : y) { }
There's an extra check there that doesn't do anything.
The logic behind the latter is much harder to grasp exactly, IMO:
- If x is truthy, then true,
- If x is falsey and not nullish, then false,
- Else the boolean coercion of y
vs the former:
- If x is falsey then false
- Else the boolean coercion of y
It's just A lot simpler to read and understand the non-nullish-coalescing form, IMO.
Impacted Configurations
No response
Additional Info
No response
Metadata
Metadata
Assignees
Labels
Go ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueThis change will require a new major version to be releasedThis change will require a new major version to be releasedPlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Issues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-pluginProposal for an addition, removal, or general change to a preset configProposal for an addition, removal, or general change to a preset config