You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Flag boolean in comparison operator operands as errors #15506
At least I have used it in the past to indicate a "comparable" that was not any (i.e. couldn't do anything with it other than compare; using any would allow property access and other shenanigans).
In this specific case, it was a function that received a function that produces an ordered list of sorting keys; where the value of the sorting keys are anything comparable. As the function doesn't need the keys to be anything in particular (besides comparable), they were typed as {} (instead of any). At the time that included both numbers and Date objects.
Speaking of which, are Date objects comparable because of spec magic, or because of Symbol.toPrimitive 🤔
Maybe late to the party, but I think Date should be comparable as well. It's true that the arithmetic operators yield strange results, but AFAIK the relational ones do not and are frequently used in JS sources.
As the comments stand now, I don't think this issue is a clear duplicate, and if we're keeping addressing that issue in this thread, then at least I want to make it clear. As the reporter Moved to @ad-si (@adius) said, it would be nice if typescript produced a warning for below (d1, d2 are Dates)
I'd like to take this one (Flag boolean in comparison operator operands as errors). I'll look into the root cause and follow up with a PR. (claiming via Stella (@LeonxLJX))
I'd like to take this one (Flag boolean in comparison operator operands as errors). I'll dig into the root cause and follow up with a PR shortly. (claiming via Stella (@LeonxLJX))
I'd like to take this one (Flag boolean in comparison operator operands as errors). I'll look into the root cause and follow up with a PR. (claiming via Stella (@LeonxLJX))
Activity
dmichon-msft commentedon May 2, 2017
Well, that is the most concise way of writing:
RyanCavanaugh commentedon May 8, 2017
Accepting PRs: Disallow non-
any/number/stringoperands on either side of<,>, etc.. Should be an easy changeJessidhia commentedon May 10, 2017
Should
{}also be comparable?At least I have used it in the past to indicate a "comparable" that was not
any(i.e. couldn't do anything with it other than compare; usinganywould allow property access and other shenanigans).DanielRosenwasser commentedon May 10, 2017
Could you elaborate on the scenario? What was the run-time value supposed to be?
Jessidhia commentedon May 10, 2017
In this specific case, it was a function that received a function that produces an ordered list of sorting keys; where the value of the sorting keys are anything comparable. As the function doesn't need the keys to be anything in particular (besides comparable), they were typed as
{}(instead ofany). At the time that included bothnumbers andDateobjects.Speaking of which, are
Dateobjects comparable because of spec magic, or because ofSymbol.toPrimitive🤔RyanCavanaugh commentedon May 10, 2017
Extreme spec magic; see #2361 (comment)
FabianLauer commentedon Jun 12, 2017
I've just taken a stab at this issue. The conformance tests for comparison operators work as expected. However, a few tests still fail, such as:
... or ...
Am I right to assume that this is an issue with (graceful) parsing? If so, should I deal with this in a new issue?
I've not opened a PR yet, BTW. Can do though if you prefer to. Any guidance is much appreciated 🙂
mhegazy commentedon Jun 12, 2017
yes.
gcnew commentedon Jun 14, 2017
Maybe late to the party, but I think
Dateshould be comparable as well. It's true that the arithmetic operators yield strange results, but AFAIK the relational ones do not and are frequently used in JS sources.staeke commentedon Feb 16, 2018
Marin Marinov (@gcnew) Came here from issue #17119
As the comments stand now, I don't think this issue is a clear duplicate, and if we're keeping addressing that issue in this thread, then at least I want to make it clear. As the reporter Moved to @ad-si (@adius) said, it would be nice if typescript produced a warning for below (
d1,d2areDates)As Marin Marinov (@gcnew) pointed out
<,>,<=,>=work fineFlag non-any/number/string operands on either side of comparison as e…
Flag non-any/number/string operands on either side of comparison as e…
Flag non-any/number/string operands on either side of comparison as e…
Flag non-any/number/string operands on either side of comparison as e…
Flag non-any/number/string operands on either side of comparison as e…
Richard-Lynch commentedon Sep 27, 2019
Working on this, I’ll follow up with a PR via Bloomberg in the by Monday
HersiYussuf commentedon Jun 1, 2024
I would love to work on this if no one hasn't already or working on it now with a bit a of help!!
HersiYussuf commentedon Jun 1, 2024
I want to work with on it, can I ?
LeonxLJX commentedon Sep 1, 2026
I'd like to take this one (
Flag boolean in comparison operator operands as errors). I'll look into the root cause and follow up with a PR. (claiming via Stella (@LeonxLJX))LeonxLJX commentedon Sep 1, 2026
I'd like to take this one (
Flag boolean in comparison operator operands as errors). I'll dig into the root cause and follow up with a PR shortly. (claiming via Stella (@LeonxLJX))LeonxLJX commentedon Sep 1, 2026
I'd like to take this one (
Flag boolean in comparison operator operands as errors). I'll look into the root cause and follow up with a PR. (claiming via Stella (@LeonxLJX))