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

transform-decorators-legacy bug #13

Closed
kmalakoff opened this Issue Dec 19, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@kmalakoff

kmalakoff commented Dec 19, 2015

From: https://phabricator.babeljs.io/T2645

@loganfsmyth: I tried on the day of the latest release a few days ago, but had to stop because I couldn't get it to work with mobservable. I'm trying again today and trying to track down the problems....

First problem: Uncaught Error: Decorating class property failed. Please ensure that transform-class-properties is enabled my .babelrc has stage-1 enabled:

{
  presets: ['es2015', 'stage-1', 'react'],
  plugins: ['add-module-exports',  'transform-decorators-legacy']
}

If I manually add transform-class-properties (maybe I'm configuring incorrectly?) I do not get the warning:

{
  presets: ['es2015', 'stage-1', 'react'],
  plugins: ['add-module-exports', 'transform-class-properties', 'transform-decorators-legacy']
}

but I run into a second problem:

class MyClass {
  @observable hello = {things: []};

  @observable get world() { return this.hello.things; }
}

The world decorator is added, but the hello one is missing from the class decoration section. So it looks like there is a change / bug in how decorators handle class properties...(other more simple ones like @observable hello = null; are skipped too)

@loganfsmyth

This comment has been minimized.

Owner

loganfsmyth commented Dec 20, 2015

Thanks for the report, it looks like the first is probably an edge case that I missed. I'm thinking that class properties aren't currently working on classes that have parent classes. Does that seem likely to be the issue for the class that is throwing Decorating class property failed. Please ensure that transform-class-properties is enabled? I added that error exactly because I was worried I'd missed instances, so at least it's working :D

I think your second issue may be a side-effect of your "fix" first the first. Adding 'transform-class-properties' to your plugin list before the decorator plugin looks like it'll actually delete all the decorated class props before they can be processed by the decorator plugin, so if you revert that to just stage-1 and I fix the first issue, I think you'll be set.

@loganfsmyth

This comment has been minimized.

Owner

loganfsmyth commented Dec 20, 2015

Okay, I've pushed out a 1.3.4 to address this. Can you report back and let me know if it fixes your issue? Update decorators-legacy and delete 'transform-class-properties' from your plugins list and I think things should work.

@kmalakoff

This comment has been minimized.

kmalakoff commented Dec 20, 2015

Excellent! I've done the steps you suggested and tested my build with Babel 6...and it works!

I'm going to unsubscribe from https://phabricator.babeljs.io/T2645 since I have what I need now. If you want to write a quick note there to respond to my question about the repurposing of the issue, it might help people decide to unsubscribe (I also find it a little spammy / chatty...it would be great if there weren't notification emails for people being added and removed be default).

I really appreciate you writing this plugin to get people over to Babel 6! Onto the future...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment