LiteMol
LiteMol copied to clipboard
Cannot access value defined by `const enum` internally
In my project, after import LiteMol
as an external library, I want to access value internally defined by const enum
, i.e. LiteMol.Visualization.Selection.Action.xxx
, but it seems not possible due to the pitfalls described here.
So, instead of code like this:
model.applySelection([1, 2, 3], LiteMol.Visualization.Selection.Action.Select)
I have to use literal value as a workaround:
model.applySelection([1, 2, 3], 1)
Is there any better solutions?
I am afraid using the const value is the only option here (or copy pasting the entire enum to your code and using it there).
Thanks for your feedback!
For now I will just use const value, but I think this issue is possible to be solved by rebuilding the whole package with the compiler option preserveConstEnums
set to true
. So maybe in the future I can create a PR?
Yes, although I think there will be some more issues with namespaces and the isolated modules. The const enums aren't used that much (and I wasn't aware of the drawbacks when I coded this).
Btw if you are just integrating a new viewer, I would recommend you use https://molstar.org instead.