Arc2D
Arc2D copied to clipboard
Deprecate @traits decorator
@traits() is deprecated in favor of .with(). The @traits decorator can only run after a class is defined and will overwrite methods defined in the class in place, modifying the Class prototype and won't allow super() calls.
New Syntax:
//---------------------native class-based traits-----------------
class TraitX {
foo(){
alert("foo X")
}
}
class TraitZ {
zee(){
alert("zee")
}
}
//---------------------classes that mix in traits-----------------
class Y {
constructor(){
alert("cctor of Y")
}
bar(){
alert("bar")
}
}
class T extends Y.with(TraitX,TraitZ) {
constructor(){
super();
this.foo()
}
foo(){
alert("foo T");
super.foo();//from TraitX
this.bar()//from Y
this.zee()//from TraitZ
}
}
The above is valid JavaScript. And will stay supported.
NEW PROPOSAL
As an added enhancement, modify transpiler to interpret the following cleaner syntax:
class T extends Y with TraitX, TraitZ {
constructor(){
super();
this.foo()
}
foo(){
alert("foo T");
super.foo();//from TraitX
this.bar()//from Y
this.zee()//from TraitZ
}
}
Traits deprecated message added.
Runtime js parsable method supported: class T extends Y.with(TraitX,TraitZ) { }