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

global-assignment-to-default-export should allow prototype assignments #138

Closed
GoodForOneFare opened this issue May 26, 2016 · 5 comments
Closed
Labels

Comments

@GoodForOneFare
Copy link
Member

This is currently prevented, but think it's necessary to fully transform Coffee class properties.

class Shopify.Foo
  foo: 'bar'
  @qux: 'foobar'

Should be allowed to translate to:

class Shopify.Foo {
  qux = 'foobar';
}

Shopify.Foo.prototype.foo = 'foobar';
@GoodForOneFare GoodForOneFare changed the title global-assignment-to-default-export shouldn't prevent prototype assignments global-assignment-to-default-export should allow prototype assignments May 26, 2016
@lemonmade lemonmade added the bug label Jun 6, 2016
@lemonmade
Copy link
Member

Another possibility here is just translating them to class instance properties, but getting esify to warn if it finds any of them in the code.

@lemonmade
Copy link
Member

Still around after the decaf merge?

@GoodForOneFare
Copy link
Member Author

Yep, still around. I have a transform-based workaround in a branch somewhere, but I think we can finesse some problems away with a minor decaf change.

Class name should be unique, so we should be able to strip out the Shopify part, and have the same result without breaking anything.

i.e., instead of outputting

Shopify.Foo = class Foo {};
Shopify.Foo.prototype.bar = 'bar';

it should produce

Shopify.Foo = class Foo();
Foo.prototype.bar = 'bar';

^ That should be safe, even in mainline decaf.

@GoodForOneFare
Copy link
Member Author

I'll dig out the branch with the transform fix and submit as a PR this morning.

@GoodForOneFare
Copy link
Member Author

Fixed by #172.

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

No branches or pull requests

2 participants