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

Harmony: Shorthand functions in objects do not add the shorthand flag #320

Closed
qfox opened this issue Feb 8, 2015 · 8 comments
Closed

Harmony: Shorthand functions in objects do not add the shorthand flag #320

qfox opened this issue Feb 8, 2015 · 8 comments

Comments

@qfox
Copy link

qfox commented Feb 8, 2015

Code:

var obj = {
  myfunc() { return null; }
}

myfunc node doesn't have truthy shorthand property.

{ type: 'Property',
  key:
   { type: 'Identifier',
     name: 'myfunc',
     range: [ 16, 22 ],
     loc: { start: [Object], end: [Object] },
     parentNode: [Circular],
     parentCollection: [ undefined ] },
  value:
   { type: 'FunctionExpression',
     id: null,
     params: [],
     defaults: [],
     body: { ... }, ... },
  kind: 'init',
  method: true,
  shorthand: false, // !!! here it is
  computed: false,
  parentNode: ...

Ref jscs-dev/node-jscs#1013

@mikesherov mikesherov changed the title ES6 feature: Shorthand functions in objects Harmony: Shorthand functions in objects do not add the shorthand flag Feb 8, 2015
@michaelficarra
Copy link
Contributor

It has the method flag. shorthand must refer to {a} style properties, no?

edit: You are probably confused because these are just called methods, not "shorthand" methods. {a} properties are called shorthand properties.

@qfox
Copy link
Author

qfox commented Feb 8, 2015

@michaelficarra yes, probably. Does it standardized? What's the difference between foo : function bar() { } and fooBar() { }?

@michaelficarra
Copy link
Contributor

The former can refer to itself by name. The latter can make super method calls and has a bound this.

@qfox
Copy link
Author

qfox commented Feb 8, 2015

@michaelficarra okay. What's about:

var myfunc = function () { return 'asd'; };
var myobj = { myfunc };
console.log(myobj.myfunc()); // asd

Here I have myfunc and it's shorthand but not a method, right? That's very confusing.

@michaelficarra
Copy link
Contributor

Yes. Not confusing to me. The flag is on the property, not the value.

@qfox
Copy link
Author

qfox commented Feb 8, 2015

So you totally sure that it shouldn't have shorthand truthy?

Oh. As I see, method flag is only set for { myfunc() { } } notation. So I should use it for methods as well as shorthand for properties. Right?
Just to be sure: does method flag is used for something else?

@michaelficarra
Copy link
Contributor

Nope, that's what you're looking for.

@qfox
Copy link
Author

qfox commented Feb 8, 2015

@michaelficarra Thanks!

@qfox qfox closed this as completed Feb 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants