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

Flag bool in less/greater than comparison as error #16515

Closed
wants to merge 4 commits into from
Closed

Flag bool in less/greater than comparison as error #16515

wants to merge 4 commits into from

Conversation

FabianLauer
Copy link

Fixes #15506.

This PR flags boolean operands in comparisons with <, >, <= and >= as errors, for example:

var a = true;
var b = 123;
var c = a > b;
        ~~~~~
> error TS2365: Operator '<' cannot be applied to types 'bool' and 'number'.

Some baselines have changed that I didn't expect to, but mhegazy confirmed that they're due to graceful parsing (see issue).

Hope I didn't miss too much. Feedback is very welcome 😃

Fabian Lauer added 4 commits June 12, 2017 12:01
Updated baselines as required for #15506, specifically to disallow any non-any/number/string operands on either side of `<`, `>`, `<=` and `>=`.
@gcnew
Copy link
Contributor

gcnew commented Jun 14, 2017

I think the expectation is only number, string and any to be comparable as per #15506 (comment).

@mhegazy
Copy link
Contributor

mhegazy commented Sep 7, 2017

As gcnew noted, number, string, and any should be allowed.

@microsoft microsoft deleted a comment from msftclas Sep 27, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Nov 7, 2017

Closing for now. please reopen with the suggested changes.

@mhegazy mhegazy closed this Nov 7, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants