Bad error message for enum initializers #24210
Labels
Bug
A bug in TypeScript
Domain: Error Messages
The issue relates to error messaging
Good First Issue
Well scoped, documented and has the green light
Help Wanted
You can do this
Milestone
TypeScript Version: [email protected]
Search Terms: enum infinity, TS2553, enum undefined
Code 1
Expected behavior: No string valued member at all. Maybe the error message is wrong.
Actual behavior:
What does the 0 mean?
Playground Link: here
Code 2
Expected behavior: Maybe?
Actual behavior: No error at all!
So what's
TestEnum.undefined
,TestEnum.NaN
,TestEnum.Infinity
,-TestEnum.Infinity
?Playground Link: here
Related Issues:
Issue #21959: "It is a compile time error for constant enum expressions to be evaluated to NaN or Infinity."
PR #22022: "disallow nan and infinity in enum member" is made for the previous issue
I think this is not duplicated as #21959 and #22022 are talking about making undefined/NaN/Infinity an error in const enum instead of making them generate correct code in non-const enum.
The text was updated successfully, but these errors were encountered: