Since we required methods defined within class definitions non-enumerable by
default, I think we should discourage people to do things like:
class Foo { … }
bar = () => {}
Foo.prototype.bar = bar;
Foo.prototype.addtionalMethod = () => {}
Maybe two new syntaxes could be allowed in es7?
class Foo {
...
bar: bar
}
partial class Foo {
addtionalMethod() {}
}
The first allows adding an existing function to a new class. The second allows
adding a new method to an existing class. The first syntax probably needs a bit
work though, because I see there were some discussions about supporting
prototypal properties, and if these properties should be enumerable by default,
we probably need different syntaxes for adding properties and methods.
These two should cover the most use cases for Object.defineProperty and
Object.defineProperties (which are too verbose to encourage people to use I
believe).
What do you think?
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss