-
Notifications
You must be signed in to change notification settings - Fork 67
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
ES6 methods and @decorators #159
Comments
|
Yes, I had a problem, and I wasted a day to catch it - I have one function that enumerate methods to find some that have specific attribute (with es5 - works fine). The problem is that js-code use one syntax for es5 (prototype) and another for es6 (class)*, while RS-code doesn't have any differeсe in syntax, but in behaviour (with --es6 or not). And the fact that it could be a problem for only specific cases makes it worse. It's not the issue of Rapydscript self, but I think it deserves some warnings/attentions in the doc. |
Now, class methods @decorations compile to Object.defineProperties({ ... enumerable : false})
Fix ES6 class methods @decorators (issue atsepkov#159)
In ES6 all methods are 'non-enumerable' by default, but in es5 - vise versa! So, code written for es5 may be crash on es6 if there are any
for ... in some.prototype
(uncatchable bugs will be provided, that's worse).Todays es6 @decorator implementation is just
class.prototype.meth = decorator(class.prototype.meth)
that makes the method enumerable! So, @decorator has side unexpected effect! It may be fixed by moving 'decorations' into class vars defs (means Object.defineProperties with enumerable=false).The text was updated successfully, but these errors were encountered: