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

Cannot decorate Symbol expression members #59

Open
jka6502 opened this issue Feb 20, 2017 · 1 comment
Open

Cannot decorate Symbol expression members #59

jka6502 opened this issue Feb 20, 2017 · 1 comment

Comments

@jka6502
Copy link

jka6502 commented Feb 20, 2017

Using a decorator on a Symbol class member throws:

function C(target, property, descriptor) {
   return descriptor;
}

const B = Symbol();

class A {

   @C
   [B] = null;

}

The following error, in the above case:

                       return decorator(target, property, desc) || desc;
                               ^

TypeError: decorator is not a function

Is this intended to work?

I see in the current decorators spec (2.1.1 - 1. Let propKey be the result of evaluating propertyName), this will work once that reaches implementation, but is there a specific reason not to for the legacy transform (would it break existing modules, was it explicitly disallowed in the original proposal)?

@jka6502
Copy link
Author

jka6502 commented Feb 21, 2017

Just to clarify, the above example is using transform-class-properties too - but attempting to decorate a Symbol expression 'named' method also errors - though not the same error - in that case, the error appears to be thrown from the babel parser, rather than the plugin.

function B(target, property, descriptor) {}

const C = Symbol();

class A {

	@B
	[C]() {}

}

throws:

SyntaxError: .../file.js: Unexpected token (14:7)
  12 |
  13 |  @B
> 14 |  [C]() {}
  15 |
  16 | }
 at Parser.pp.raise (...node_modules/babylon/lib/parser/location.js:22:13)
 at Parser.pp.unexpected (...node_modules/babylon/lib/parser/util.js:89:8)
 at Parser.pp.parseIdentifier(...node_modules/babylon/lib/parser/expression.js:1053:10)
 at Parser.pp.parsePropertyName (...node_modules/babylon/lib/parser/expression.js:858:117)
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant