Skip to content

HttpClient - 'if' condition always true? #19223

@snerks

Description

@snerks

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ x ] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

In the following source code for HttpClient:

if (!!options.headers !== undefined) {

The expression appears to evaluate to true always, since the result of a double-exclamation on the LHS (!!options.headers) will be boolean (true | false), such that it is always !== undefined.

Expected behavior

The expression could evaluate to false, to match the intention.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

The intent is unclear, given that the expression appears to always evaluate to true.

Environment


Angular version: X.Y.Z
N/A

Browser:
N/A
 
For Tooling issues:
N/A

Others:
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: common/httpIssues related to HTTP and HTTP Clientfreq1: lowrefactoringIssue that involves refactoring or code-cleanup

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions