I know traits are not something that will make it into ES6. This was the suggested alternative on the mailing list:
class Thing extends mixin(Base, Trait1, Trait2) {...} Unfortuantly since rev32 this is now seems impossible, as a custom implementation of traits would need to this to work: class Foo { constructor() {} } function ctor() { Foo.call(this); // <— illegal? } ctor.prototype = Object.create(Foo.prototype); ctor.prototype.constructor = ctor; new ctor(); The code I’m working with makes extensive use of traits. Simple inheritance just doesn’t work for what I’m trying to do (and avoid duplicating code). I’m using 6to5, and now Trait.call(this) is failing since I was defining my traits as classes. I can fix this by not using classes for my traits, and 6to5 or traceur cannot enforce Foo.call(this) from being illegal since “this instanceof Foo” is true, but it is sure to break on the real thing. Hopefully I’m wrong in that Foo.call(this) is illegal, but if it is, this is a devastating change, especially when traits are scheduled for ES7 or later. -- Luke _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss