-
-
Notifications
You must be signed in to change notification settings - Fork 623
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
Cannot use custom decorator on class property? #541
Comments
current version leaves the property non-configurable.this prevents aurelia from observing the property see SpoonX/aurelia-orm#177 see aurelia/framework#541
ps: this is a babel issue. i tried with typescript (2 i think), and did not have this problem |
Yep, babel issue. |
The babel guys (from the Issue link above) seem to disagree that it's a Babel issue, referencing semi-recent changes to TC39? |
@doublemarked Can you get a link to the latest spec and find out what the change was? |
@EisenbergEffect I don't know where this is in the spec, but I believe this discussion here is highly relevant: tc39/proposal-class-public-fields#36 @doktordirk started discussing with them there as well but things seem to have stalled. Anyways - I don't feel informed enough to determine whether it's a problem in Aurelia or in Babel, but I encountered the problem last night and think it would be good to reopen the issue somewhere. Currently it's marked closed in both projects. |
here's a fix: // fix for babels property decorator
export function ensurePropertyIsConfigurable(target, propertyName, descriptor) {
if (descriptor && descriptor.configurable === false) {
descriptor.configurable = true;
if (!Reflect.defineProperty(target, propertyName, descriptor)) {
logger.warn(`Cannot make configurable property '${propertyName}' of object`, target);
}
}
} usage:` /*
* @decorator
*/
export function aDecoator() {
return function(target, propertyName, descriptor) {
ensurePropertyIsConfigurable(target, propertyName, descriptor);
/* your code */
};
} |
I'm submitting a bug report
1.0.1
OSX 10.11
6.2.2
3.9.5
JSPM 0.16.41
Chrome 52.0.2743.82
ESNext
Current behavior:
When adding custom decorator, i am no longer able to bind to properties on a class. I instead get errors like this:
WARN [property-observation] Cannot observe property 'brands' of object
Expected/desired behavior:
It should allow me to utilize my own custom decorator and still bind to the property.
I tried replicating the issue by forking https://gist.run/?id=7542e061bc940cde506b&sha=6821c521a6c7bae6f59a36fb8628ecd1032b2d10, but I could not replicate it. I'm beginning to wonder if that gist is running the old Babel 5, and that this is only an issue with Babel 6 with the legacy decorator plugin.
The text was updated successfully, but these errors were encountered: