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
Because the specification for JS private class properties does not support dynamic lookup, macro decorators such as @reads() etc are not able to work with a string path passed to the decorator, since the decorator can't dynamically pick the string path from the this context - see here.
The text was updated successfully, but these errors were encountered:
So the decorator executes when the class is defined, not when the class is initialized. This means that this in your example code is bound to the external scope, not the class itself. In order to access the private field, you would need to be passed a function which can access the value instead, which could then be called with the class instance as the backing value:
This function would also need to have access to the private name, which is not a normal thing that can happen. It would need to be included in the spec for decorators I believe. This is a good thing to bring up in that proposal, maybe you could open an issue on the decorators repo? https://github.com/tc39/proposal-decorators
Previously discussed on Discord - https://discord.com/channels/480462759797063690/608346628163633192/781996880547938344
TLDR;
Because the specification for JS private class properties does not support dynamic lookup, macro decorators such as
@reads()
etc are not able to work with a string path passed to the decorator, since the decorator can't dynamically pick the string path from thethis
context - see here.The text was updated successfully, but these errors were encountered: