-
Notifications
You must be signed in to change notification settings - Fork 27.1k
HttpClient - 'if' condition always true? #19223
Copy link
Copy link
Closed
Labels
area: common/httpIssues related to HTTP and HTTP ClientIssues related to HTTP and HTTP Clientfreq1: lowrefactoringIssue that involves refactoring or code-cleanupIssue that involves refactoring or code-cleanup
Description
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:
angular/packages/common/http/src/client.ts
Line 355 in b6431c6
| 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/AReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: common/httpIssues related to HTTP and HTTP ClientIssues related to HTTP and HTTP Clientfreq1: lowrefactoringIssue that involves refactoring or code-cleanupIssue that involves refactoring or code-cleanup