Skip to content

It is a compile time error for constant enum expressions to be evaluated to NaN or Infinity.  #21959

Closed

Description

@kannanwisen

Hi,

The documentation says

It is a compile time error for constant enum expressions to be evaluated to NaN or Infinity.

But the below code does not throw any compile time error

enum FMixed {
    Data1 = 10 + 0.0 / 0.0,
    Data2 = 0 / 0,
    Data3 = 10 / 0.0
}

console.log("FMixed.Data1 is "+FMixed.Data1);

TypeScript Version is 2.7.1

Activity

  1. added
    BugA bug in TypeScript
    and removed
    Working as IntendedThe behavior described is the intended behavior; this is not a bug
    on Feb 15, 2018
  2. added this to the milestone on Feb 17, 2018
  3. kannanwisen commented on Feb 20, 2018

    @kannanwisen
    Author

    Better to disallow NaN and Infinity in enum member value

  4. orzFly commented on May 17, 2018

    @orzFly

    undefined shouldn't be permitted in it as well.

  5. modified the milestones: , TypeScript 3.0 on May 23, 2018
  6. locked and limited conversation to collaborators on Jul 31, 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

    BugA bug in TypeScriptFixedA PR has been merged for this issueHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions