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

Object Method Shorthand #13

Open
xjamundx opened this issue Jan 20, 2016 · 1 comment
Open

Object Method Shorthand #13

xjamundx opened this issue Jan 20, 2016 · 1 comment

Comments

@xjamundx
Copy link
Contributor

Convert object methods into shorthand

{
    x: function() { }
}

// into
{
    x() {}
}
@jsnmoon
Copy link
Collaborator

jsnmoon commented Mar 17, 2017

For anyone interested in picking up this task, it'll be important to distinguish the difference between the two cases.

Case A: (anonymous function)

{
  x: function() { ... }
}

Case B: (named function)

{
  x: function someNamedFunction() { ... }
}

Automatically converting the unnamed function shouldn't cause any issues, but converting the named function can be problematic if the named function involves recursion or event binding/unbinding - a good example is documented here.

If we're ok letting this be a potentially breaking transformation, I think we should go ahead and convert both cases. If we want this to be a safe transformation, I think we should only transform case A.

As an aside, it might be nice to have the ability to an allowUnsafe flag for this transform; we can support both transformations while only enabling the safe transformation by default.

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

2 participants