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 Rest/Spread Properties #1588

Closed
ariya opened this issue Oct 9, 2016 · 19 comments
Closed

Object Rest/Spread Properties #1588

ariya opened this issue Oct 9, 2016 · 19 comments
Assignees
Labels
Milestone

Comments

@ariya
Copy link
Contributor

ariya commented Oct 9, 2016

New productions:

PropertyDefinition[Yield] ::
  ...  AssignmentExpression[In, ?Yield]

ObjectAssignmentPattern[Yield] ::
  {AssignmentRestProperty[?Yield]opt}
  {AssignmentPropertyList[?Yield]  ,  AssignmentRestProperty[?Yield]opt}

AssignmentRestProperty[Yield] ::
  ...  DestructuringAssignmentTarget[?Yield]

ObjectBindingPattern[Yield] ::
  {BindingRestProperty[?Yield]opt}
  {BindingPropertyList[?Yield]  ,  BindingRestProperty[?Yield]opt}

BindingRestProperty[Yield] ::
  ...  BindingIdentifier[?Yield]
  ...  BindingPattern[?Yield]

AST changes:

extend interface ObjectPattern {
    properties: [ AssignmentProperty | RestElement ];
}

extend interface ObjectExpression {
    properties: [ Property | SpreadElement ];
}

References:

@ariya ariya added the es2017 label Oct 9, 2016
@ariya ariya added this to the 4.0 milestone Oct 9, 2016
@hzoo
Copy link

hzoo commented Oct 10, 2016

ESTree for rest/spread: https://github.com/estree/estree/blob/master/experimental/rest-spread-properties.md

@ariya ariya mentioned this issue Oct 10, 2016
27 tasks
@hzoo
Copy link

hzoo commented Oct 10, 2016

And it's stage-3 right now (not in es2017)

@ariya ariya self-assigned this Jan 16, 2017
ariya added a commit to ariya/esprima that referenced this issue Jan 17, 2017
@ariya ariya closed this as completed in 13e5283 Jan 20, 2017
@ariya ariya mentioned this issue Feb 1, 2017
12 tasks
@ariya ariya changed the title ES2017: Object Rest/Spread Properties Object Rest/Spread Properties Feb 1, 2017
@ariya ariya added es2018 and removed es2017 labels Feb 1, 2017
@ariya ariya modified the milestones: 5.0, 4.0 Feb 1, 2017
ariya added a commit to ariya/esprima that referenced this issue Feb 25, 2017
ariya added a commit to ariya/esprima that referenced this issue Feb 26, 2017
ariya added a commit that referenced this issue Feb 26, 2017
@ariya
Copy link
Contributor Author

ariya commented Mar 5, 2017

Originally, the AST changes involved the addition of two new nodes RestProperty and SpreadProperty:

interface RestProperty <: Node {
    type: "RestProperty";
    argument: Expression;
}

interface SpreadProperty <: Node {
    type: "SpreadProperty";
    argument: Expression;
}

and the modifications to ObjectPattern and ObjectExpression:

extend interface ObjectPattern {
    properties: [ AssignmentProperty | RestProperty ];
}

extend interface ObjectExpression {
    properties: [ Property | SpreadProperty ];
}

However, based on the discussion in estree/estree#145, the consensus is that the AST change will be simplified to the reuse of the existing RestElement and SpreadElement and thus the modifications to ObjectPattern and ObjectExpression are also simplified to:

extend interface ObjectPattern {
    properties: [ AssignmentProperty | RestElement ];
}

extend interface ObjectExpression {
    properties: [ Property | SpreadElement ];
}

@ariya
Copy link
Contributor Author

ariya commented Mar 28, 2017

As of March 2017, it's in Stage 3 (https://github.com/tc39/proposals).

@concubicycle
Copy link

Is this currently working?

@ariya
Copy link
Contributor Author

ariya commented Jun 6, 2017

Is this currently working?

If you use the master branch. Otherwise, keep an eye on https://github.com/jquery/esprima/projects/2.

@idevelop
Copy link

idevelop commented Jan 8, 2019

Hey @ariya, is version 5.0 scheduled for a release date?

@LeoEatle
Copy link

When will 5.0 release?

@danielo515
Copy link

Eslint does support this, and eslint uses (by default) esprima. How are they doing this?

@asapach
Copy link

asapach commented Apr 26, 2020

ESLint uses Espree: https://github.com/eslint/espree

@danielo515
Copy link

Oh, a misread from hours of not sleeping. Thanks!

@ctjlewis
Copy link

ctjlewis commented Aug 16, 2020

Three years later, still can't parse a spread operator?

@mreinstein
Copy link

There aren't any javascript runtimes that support es module syntax but lack the spread operator. At the very least I would expect esprima.parseModule to support all of the es6-isms.

Also, I'm not sure why this issue has been closed when it's not available in any releases. Isn't this kind of indirectly sweeping the problem under the rug?

@VityaSchel
Copy link

How do I replace it? I tried replacing ... with {}.apply()Unexpected identifier {, with new Object().apply()Unexpected identifier, with fake object which does not exist in code: object.apply()Unexpected identifier .. None of these work. Is there any workaround?

@ctjlewis
Copy link

This issue should not be closed.

@LeoEatle
Copy link

I publish a master version of esprima: https://www.npmjs.com/package/esprima-master
But I still suggest to use Babel or Eslint as parser. I have finished this in my project.

@0x00C5
Copy link

0x00C5 commented Nov 5, 2021

There's a solution here #2034 (comment)

@sophiawisdom
Copy link

Six years and no support for spread operator.

@VityaSchel
Copy link

VityaSchel commented Mar 25, 2022

Six years and no support for spread operator.

use babel

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

No branches or pull requests