Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decorators and plain object properties #2519

Closed
fatfisz opened this issue Oct 10, 2015 · 5 comments
Closed

Decorators and plain object properties #2519

fatfisz opened this issue Oct 10, 2015 · 5 comments
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@fatfisz
Copy link
Contributor

fatfisz commented Oct 10, 2015

I understand that when it comes to property initializers, there might be a need to perform some hocus-pocus with the initializer property, which effectively prevents modifying descriptor's value (it is overwritten by the result of the initializer function in the end).

But for plain objects descriptor's value can be left intact. Accessing it by a decorator is currently unnecessarily prevented.

Could it be not so? If yes, then I volunteer to create a PR with a fix for that :)

@fatfisz
Copy link
Contributor Author

fatfisz commented Oct 10, 2015

For now I'm using a decorator that fixes this:

function fixDescriptor(target, key, descriptor) {
  if (descriptor.initializer) {
    descriptor.value = descriptor.initializer.call(target);
    delete descriptor.initializer;
  }
}

... but remembering to put it in front of all properties isn't something I'm looking forward to.

@sebmck
Copy link
Contributor

sebmck commented Oct 10, 2015

There's nothing to fix here. This is in the specification/proposal and it wont be changed unless it is there. See the javascript-decorators repo for more information.

@sebmck sebmck closed this as completed Oct 10, 2015
@fatfisz
Copy link
Contributor Author

fatfisz commented Oct 10, 2015

Could you please point me to the right place, because in the README.md file there is nothing written about plain object properties, and INITIALIZER_INTEROP.md is only concerned with classes.

I've already read that spec carefully before. If you're not convinced, then maybe I'll take it to the spec so that this case will be clarified there.

@sebmck
Copy link
Contributor

sebmck commented Oct 10, 2015

wycats/javascript-decorators#36

On Sat, Oct 10, 2015 at 9:22 PM, Rafał Ruciński notifications@github.com
wrote:

Could you please point me to the right place, because in the README.md file there is nothing written about plain object properties, and INITIALIZER_INTEROP.md is only concerned with classes.

I've already read that spec carefully before. If you're not convinced, then maybe I'll take it to the spec so that this case will be clarified there.

Reply to this email directly or view it on GitHub:
#2519 (comment)

@babel-bot
Copy link
Collaborator

Comment originally made by Rafał Ruciński (fatfisz) on 2016-03-03T23:42:45.000Z

@sebmck I've recently had a discussion with a peculiar individual in the https://github.com/wycats/javascript-decorators repo (I saw that you too commented on his rude demeanor). That reminded me of this issue, and while looking for it I also found https://phabricator.babeljs.io/T2005, an earlier issue concerning the same problem.
So, for what it's worth, sorry for not searching carefully enough to see if I won't be creating a duplicate. I hope I wasn't rude too much.
And thanks for sticking to the most actual spec, even if some people don't agree with some parts of it.

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 7, 2018
@lock lock bot locked as resolved and limited conversation to collaborators May 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

3 participants