-
Notifications
You must be signed in to change notification settings - Fork 183
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
Reflect.getMetadata not working on proxified objects #106
Comments
I’d think the Proxy has to allow you to do that, by having Proxy traps and a target argument to the Reflect method - otherwise you can’t/shouldn’t. |
@ljharb Thanks for your feedback. Maybe I am missing something here, but I guess everything should be transparent, and the one-to-one match between proxy methods traps and Reflect API should be kept consistent. If in native Reflect.apply()
Reflect.construct()
Reflect.defineProperty()
Reflect.deleteProperty()
Reflect.get()
Reflect.getOwnPropertyDescriptor()
Reflect.getPrototypeOf()
Reflect.has()
Reflect.isExtensible()
Reflect.ownKeys()
Reflect.preventExtensions()
Reflect.set()
Reflect.setPrototypeOf() Then handler.apply()
handler.construct()
handler.defineProperty()
handler.deleteProperty()
handler.get()
handler.getOwnPropertyDescriptor()
handler.getPrototypeOf()
handler.has()
handler.isExtensible()
handler.ownKeys()
handler.preventExtensions()
handler.set()
handler.setPrototypeOf() Now if Reflect.defineMetadata();
Reflect.hasMetadata();
Reflect.hasOwnMetadata();
Reflect.getMetadata();
Reflect.getOwnMetadata();
Reflect.getMetadataKeys();
Reflect.getOwnMetadataKeys();
Reflect.deleteMetadata(); Then it should also extend handler.defineMetadata();
handler.hasMetadata();
handler.hasOwnMetadata();
handler.getMetadata();
handler.getOwnMetadata();
handler.getMetadataKeys();
handler.getOwnMetadataKeys();
handler.deleteMetadata(); Then things would be consistent. As for now and current implementation of reflect-metadata: if at any point in a third-party library some code is proxyfying an object on which I have set up metadata beforehand, then I suddenly loose access to these metadatas ... Whereas the proxy should transparently forward the Reflect.getMetadata() call to the targeted object. Things are confusing here because in the reflect-metada documentation (https://github.com/rbuckton/reflect-metadata - see Goals section), we have:
Has something been implemented somewhere regarding that? Any example available? |
I agree with you; it’s been established many times in committee that nothing is allowed on Reflect that isn’t also a proxy trap. |
@nicomouss did you find a solution other than copying metadata manually? |
@aigoncharov yes, but if there isn’t a Proxy trap, there isn’t allowed to be a corresponding function on Reflect. |
@rbuckton here's the live demo based on the code provided by @nicomouss |
Do you have any news about this issue? |
We're not planning on any further changes to how We're discussing how metadata should be handled in ECMAScript as part of the decorators proposal. Currently, we have two options under consideration:
The current implementation utilizes a |
See the right behaviour of
Reflect.get()
below, compared toReflect.getMetadata()
when a proxy is involved.My question then: how do I access an object's metadata when this object has been proxified?
Everything shouldn't be transparent like it is when using
Reflect.get()
?The text was updated successfully, but these errors were encountered: