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

Incorrect This condition will always return 'false' since JavaScript compares objects by reference, not value warning #60545

Open
johndoknjas opened this issue Nov 20, 2024 · 2 comments
Labels
Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it

Comments

@johndoknjas
Copy link

πŸ”Ž Search Terms

"this condition will always return false since javascript compares objects by reference typescript github issue"

πŸ•— Version & Regression Information

Saw this message in vscode and the typescriptlang playground.

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/PTAEHUFMBsGMHsC2lQBd5oBYoCoE8AHSAZVgCcBLA1UABWgEM8BzM+AVwDsATAGiwoBnUENANQAd0gAjQRVSQAUCEmYKsTKGYUAbpGF4OY0BoadYKdJMoL+gzAzIoz3UNEiPOofEVKVqAHSKymAAmkYI7NCuqGqcANag8ABmIjQUXrFOKBJMggBcISGgoAC0oACCbvCwDKgU8JkY7p7ehCTkVDQS2E6gnPCxGcwmZqDSTgzxxWWVoASMFmgYkAAeRJTInN3ymj4d-jSCeNsMq-wuoPaOltigAKoASgAywhK7SbGQZIIz5VWCFzSeCrZagNYbChbHaxUDcCjJZLfSDbExIAgUdxkUBIursJzCFJtXydajBBCcQQ0MwAUVWDEQC0gADVHBQGNJ3KAALygABEAAkYNAMOB4GRonzFBTBPB3AERcwABS0+mM9ysygc9wASmCKhwzQ8ZC8iHFzmB7BoXzcZmY7AYzEg-Fg0HUiQ58D0Ii8fLpDKZgj5SWxfPADlQAHJhAA5SASPlBFQAeS+ZHegmdWkgR1QjgUrmkeFATjNOmGWH0KAQiGhwkuNok4uiIgMHGxCyYrA4PCCJWljVl8sVSoA2gBGAC6PN5451QA

πŸ’» Code

console.log([1] == 1)

πŸ™ Actual behavior

Hovering over the line gives the warning This condition will always return 'false' since JavaScript compares objects by reference, not value.

πŸ™‚ Expected behavior

No warning, since the comparison results in true.

Additional information about the issue

No response

@MartinJohns
Copy link
Contributor

Same deal as #30655.

@RyanCavanaugh RyanCavanaugh added the Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it label Nov 20, 2024
@RyanCavanaugh
Copy link
Member

I don't really see much point either special-casing the == case or muddying the wording of the === case. There's no reason to write code this way and the error gets the point across

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it
Projects
None yet
Development

No branches or pull requests

3 participants