Skip to content

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

Closed
@berickson1

Description

@berickson1

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'.

Activity

normalser

normalser commented on Nov 10, 2016

@normalser
mhegazy

mhegazy commented on Nov 10, 2016

@mhegazy
Contributor

closing in favor of #10120

locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @berickson1@normalser@mhegazy

        Issue actions

          [2.1-rc] '>' operator cannot be applied to const number · Issue #12150 · microsoft/TypeScript