tc39 / proposal-decorators-previous

Decorators for ECMAScript
183 stars 16 forks source link

Questions interpreting the spec for my book #34

Open jisaacks opened 7 years ago

jisaacks commented 7 years ago

I am in the process of writing a book for Manning Publications on the newest JavaScript features, including future features that are in popular use (such as decorators)

I have some questions from the current stage-2 proposal that I would greatly appreciate if I could get answered so that I may provide the latest accurate information in my book.

It seems like class decorator function takes 3 arguments, the class/constructor being decorated, the parent class/constructor, an array of member descriptors.

The member decorator functions accept and return member descriptors.

function rename(md) {
  return Object.assign({}, md, {key: 'bar'})
}

class A {
  @rename foo = 1;
}

new A().bar // 1

Thanks so much.

jkrems commented 7 years ago

Disclaimer: Not one of the maintainers/authors. But I think I can answer some of the questions.

littledan commented 6 years ago

This proposal is still in development; I'd be hesitant to publish a hard-copy book about its details. The answers have actually changed since the time you wrote these questions. I'll get back to you with current answers soon.