Skip to content

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

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

Closed
kannanwisen opened this issue Feb 15, 2018 · 2 comments
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@kannanwisen
Copy link

kannanwisen commented Feb 15, 2018

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

@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Feb 15, 2018
@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript and removed Working as Intended The behavior described is the intended behavior; this is not a bug labels Feb 15, 2018
@RyanCavanaugh RyanCavanaugh reopened this Feb 15, 2018
@mhegazy mhegazy added this to the Community milestone Feb 17, 2018
@mhegazy mhegazy added the Help Wanted You can do this label Feb 17, 2018
@kannanwisen
Copy link
Author

Better to disallow NaN and Infinity in enum member value

@orzFly
Copy link

orzFly commented May 17, 2018

undefined shouldn't be permitted in it as well.

@mhegazy mhegazy modified the milestones: Community, TypeScript 3.0 May 23, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label May 23, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

4 participants