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

[2.1-rc] '>' operator cannot be applied to const number #12150

Closed
berickson1 opened this issue Nov 10, 2016 · 2 comments
Closed

[2.1-rc] '>' operator cannot be applied to const number #12150

berickson1 opened this issue Nov 10, 2016 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@berickson1
Copy link

TypeScript Version: 2.1.1 (RC)

In our code we use several constants at the top of typescript files to store class config data. For example, we might want to limit the number of operations that can be performed simultaneously, but tweak the value from time to time. After upgrading to typescript@rc, this code no longer compiles

Code

const maxPeople = 4;

class Race {
    // Compiles under 2.0.8, Doesn't compile under 2.1.1-rc
    multiPersonRace(): boolean {
        return maxPeople > 1;
    }
}

See https://github.com/berickson1/Playground/blob/master/constError.ts

Expected behavior:

Code compiles

Actual behavior:

constError.ts(5,16): error TS2365: Operator '>' cannot be applied to types '4' and '1'.

@normalser
Copy link

normalser commented Nov 10, 2016

#10120 #11134

@mhegazy mhegazy added the Duplicate An existing issue was already created label Nov 10, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Nov 10, 2016

closing in favor of #10120

@mhegazy mhegazy closed this as completed Nov 10, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants