Not much new activity in the GitHub repo. The code conciseness (with the underlying features) that decorators offer is to die for!
Ah, thanks!
I see the README says
The class "shape" is visible without executing the code, making decorators more optimizable for engines.
But then it goes on to show that decorators can be used like this:
function modifyShapeOfClass(klass) {
klass.prototype[Math.random()] = function() { ... }
return klass
}
@modifyShapeOfClass
class MyClass { ... }
Does that defeat the stated goal?
From the new README:
The class decorator is called only after all method and field decorators are called and applied.
We can still change the shape of the class:
let propsToAdd = []
function extraProp(_, {name}) {
propsToAdd.push(name)
return _
}
function addProps(k) {
for (const prop of propsToAdd) {
Object.defineProperty(k.prototype, prop + '_two', { ... })
}
propsToAdd.length = 0
return k
}
@addProps
class Foo {
@extraProp bar = 123
}
new Foo().bar_two
Does that mean any decorator can still make it impossible to change the class shape? Or another question is, why make something a little more difficult if people are still going to do it?
That reads like it'd be better suited as an issue there.
so given the time and advancement, are decorators going to make it into ecmascript and it's just a matter of me being patient? or could it die on the vine? im curious ( and too impatient i know )...
Decorators are currently in stage 3 GitHub - tc39/proposal-decorators: Decorators for ES6 classes
Until a proposal is stage 4 there is always some non zero chance that it won't make it into EcmaScript.
If and how long it takes to go from stage 3 to 4 is not possible to say for sure. "It depends"