You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make a rule - enum members referencing another external enum must always be numeric, or explicitly converted to a string. Otherwise, it is an error. And under `isolatedModules``, we will have to assume nothing about the value of the enum member itself.
So we will assume B is a number, and use numeric reverse-mapping emit - but C will need an explicit initializer.
Conclusion: we are leaning towards the last-mentioned rule
isolatedModulesand Cross-File Enum Member References#56153
"Who doesn't love enums?"
If you have a numeric enum member in one file, and a numberic enum that references that first one in another file...
...and a subsequent member has no initializer...
...under
isolatedModuleswe don't issue an error - we don't know what this is supposed to be.We do when
Ais a string - and if it is, we generate avoid 0for the initializer - but not if it's numeric (as above).Should we?
Probably?
A compiler doesn't know what it should perform - numbers get a reverse-map, strings don't.
Some philosophical discussion - should
isolatedModulesimply this dynamic behavior.We have a few choices.
Force people to do the auto-numbering themselves.
Emit a dynamic check using
typeof.Make a rule - enum members referencing another external enum must always be numeric, or explicitly converted to a string. Otherwise, it is an error. And under `isolatedModules``, we will have to assume nothing about the value of the enum member itself.
Bis a number, and use numeric reverse-mapping emit - butCwill need an explicit initializer.Conclusion: we are leaning towards the last-mentioned rule