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

Warning about inappropriate equality comparison with a new object #273

Open
szape89 opened this issue Jul 12, 2024 · 3 comments · May be fixed by #275
Open

Warning about inappropriate equality comparison with a new object #273

szape89 opened this issue Jul 12, 2024 · 3 comments · May be fixed by #275
Labels

Comments

@szape89
Copy link

szape89 commented Jul 12, 2024

With Angular I get the below warning message when running ng serve.

▲ [WARNING] Comparison using the "!==" operator here is always true [equals-new-object]

    angular:script/global:scripts.js:11:11451:
      11 │ ...p,u,d,g,m,f,x,v,y,V,w,S,M;if(t!=={}){for(l=t.divisions||0,w=t.s...
         ╵                                  ~~~

  Equality with a new object is always false in JavaScript because the equality operator tests object identity. You need to write code to compare the contents of the object instead. For example, use "Array.isArray(x) && x.length === 0" instead of "x === []" to test for an empty array.

Based on the warning, the issue is this line: if (ticksOptions !== {}) {

@szape89 szape89 changed the title Waning about inappropriate equality comparison with a new object Warning about inappropriate equality comparison with a new object Aug 2, 2024
@MrSuddenJoy
Copy link

Use != instead of !==

@kplindegaard
Copy link
Collaborator

This stems from the somewhat naive comparison in the source file gauge.coffee, which is where the fix should be done.

@kplindegaard kplindegaard linked a pull request Oct 19, 2024 that will close this issue
@kplindegaard
Copy link
Collaborator

@szape89 @MrSuddenJoy If you guys wanna take a look and see if this is OK, we can merge and publish this on https://www.npmjs.com/package/gaugeJS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants