Skip to content

Instantly share code, notes, and snippets.

@stefanpenner
Last active August 29, 2015 14:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save stefanpenner/ab375c2eb7d67f8f230e to your computer and use it in GitHub Desktop.

so given:

var a = {
  @myDecorator('someValue') name
};

if name is not defined, what should happen. Should it always throw, or only throw if myDecorator attempts to access descriptor.value?

today, babel emits:

var a = _createDecoratedObject([{
  key: 'name',
  decorators: [myDecorator('someValue')],
  value: name
}]);

which means name throws during the evaluation of the design.

it would seem if myDecorator never inspects descriptor.value this expression should not error.

var a = _createDecoratedObject([{
  key: 'name',
  decorators: [myDecorator('someValue')],
  get value() { return name }
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment