# Decorators. Any new progress?

**URL:** <https://es.discourse.group/t/decorators-any-new-progress/457>\
**Category:** I have questions\
**Created:** [September 6, 2020, 5:14am UTC](https://es.discourse.group/t/decorators-any-new-progress/457 "2020-09-06T05:14:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![trusktr](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/trusktr/32/183_2.png) [@trusktr](https://es.discourse.group/u/trusktr)\
**Post date:** [September 6, 2020, 5:14am UTC](https://es.discourse.group/t/decorators-any-new-progress/457/1 "2020-09-06T05:14:36Z")

</div>

Not much new activity in the GitHub repo. The code conciseness (with the underlying features) that decorators offer is to die for!

---

<div class="post-metadata">

**Author:** ![JackWorks](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/jackworks/32/260_2.png) [@JackWorks](https://es.discourse.group/u/JackWorks)\
**Post date:** [September 23, 2020, 9:43am UTC](https://es.discourse.group/t/decorators-any-new-progress/457/2 "2020-09-23T09:43:05Z")

</div>

> <https://github.com/tc39/proposal-decorators/pull/310>

---

<div class="post-metadata">

**Author:** ![trusktr](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/trusktr/32/183_2.png) [@trusktr](https://es.discourse.group/u/trusktr)\
**Post date:** [October 6, 2020, 1:19am UTC](https://es.discourse.group/t/decorators-any-new-progress/457/3 "2020-10-06T01:19:08Z")

</div>

Ah, thanks!

---

<div class="post-metadata">

**Author:** ![trusktr](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/trusktr/32/183_2.png) [@trusktr](https://es.discourse.group/u/trusktr)\
**Post date:** [October 6, 2020, 2:24am UTC](https://es.discourse.group/t/decorators-any-new-progress/457/5 "2020-10-06T02:24:42Z")

</div>

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:

```js
function modifyShapeOfClass(klass) {
  klass.prototype[Math.random()] = function() { ... }
  return klass
}

@modifyShapeOfClass
class MyClass { ... }

```

Does that defeat the stated goal?

---

<div class="post-metadata">

**Author:** ![trusktr](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/trusktr/32/183_2.png) [@trusktr](https://es.discourse.group/u/trusktr)\
**Post date:** [October 6, 2020, 3:50am UTC](https://es.discourse.group/t/decorators-any-new-progress/457/6 "2020-10-06T03:50:27Z")

</div>

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:

```js
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?

---

<div class="post-metadata">

**Author:** ![claudiameadows](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/claudiameadows/32/126_2.png) [@claudiameadows](https://es.discourse.group/u/claudiameadows)\
**Post date:** [November 23, 2020, 4:24am UTC](https://es.discourse.group/t/decorators-any-new-progress/457/7 "2020-11-23T04:24:00Z")

</div>

That reads like it'd be better suited as an issue there.

---

<div class="post-metadata">

**Author:** ![ReinsBrain](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/reinsbrain/32/1165_2.png) [@ReinsBrain](https://es.discourse.group/u/ReinsBrain)\
**Post date:** [November 22, 2022, 5:28pm UTC](https://es.discourse.group/t/decorators-any-new-progress/457/8 "2022-11-22T17:28:46Z")

</div>

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 )...

---

<div class="post-metadata">

**Author:** ![aclaymore](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/aclaymore/32/501_2.png) [@aclaymore](https://es.discourse.group/u/aclaymore)\
**Post date:** [November 22, 2022, 8:47pm UTC](https://es.discourse.group/t/decorators-any-new-progress/457/9 "2022-11-22T20:47:28Z")

</div>

Decorators are currently in stage 3 [GitHub - tc39/proposal-decorators: Decorators for ES6 classes](https://github.com/tc39/proposal-decorators)

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" 😃
