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

JSX Spread operator throws syntax error #351

Closed
zovt opened this issue Jul 5, 2016 · 11 comments
Closed

JSX Spread operator throws syntax error #351

zovt opened this issue Jul 5, 2016 · 11 comments
Labels

Comments

@zovt
Copy link

zovt commented Jul 5, 2016

for example:

const x = this.someArray.map((props) => <Component {...props} />);
@Wilfred
Copy link
Contributor

Wilfred commented Aug 18, 2016

Support for the object spread operator was released in 0cda392 (version 20160623), and added in 2a904e0.

It's not clear to me which parts of the parser are JSX related and need to be updated. Relevant JSX docs: https://facebook.github.io/react/docs/jsx-spread.html

@dgutov
Copy link
Collaborator

dgutov commented Aug 26, 2016

It seems like this would require us to support JS syntax like this first:

var b = ...c;

Is there some ESn proposal like this? Can this even make sense?

Alternatively, we'd have to parse interpolated expressions inside XML literals like functions parameters..?

@Wilfred
Copy link
Contributor

Wilfred commented Aug 29, 2016

Is there some ESn proposal like this?

... is supported in the following situations:

rest parameters, e.g. function foo(x, y, ...more) { whatever() }

spread syntax e.g. [...iterableObj, 4, 5, 6] and myFunction(-1, ...args, 2, ...[3]); and var foo = [...bar]

destructuring assignment e.g. ({a, b, ...rest} = {a:1, b:2, c:3, d:4});

So your example doesn't make sense, but you can use ... in an awful lot of contexts.

@dgutov
Copy link
Collaborator

dgutov commented Aug 29, 2016

Yes. Too bad E4X doesn't interpret { ... } like one of those contexts.

@Wilfred
Copy link
Contributor

Wilfred commented Aug 30, 2016

Alternatively, we'd have to parse interpolated expressions inside XML literals like functions parameters..?

Would there be any downsides to doing this? I'm not familiar with the js2-mode code.

@dgutov
Copy link
Collaborator

dgutov commented Aug 30, 2016

It will likely break E4X support, to some extent. Which is the (outdated) technology we actually support, not JSX.

@aaronjensen
Copy link

fwiw {...props} is a jsx specific construct. It exists and is usable even in situations where object rest and object spread is not available.

@Wilfred
Copy link
Contributor

Wilfred commented Nov 12, 2016

It looks like https://github.com/felipeochoa/rjsx-mode has solved this problem.

@zovt
Copy link
Author

zovt commented May 3, 2017

is this still a problem in this package? is the suggested rjsx-mode the fix? If so, I can close this issue as wontfix

@ibrahima
Copy link

I can confirm that using rjsx-mode (which extends js2-mode) fixes this issue, so this can probably be closed.

@dgutov dgutov added the wontfix label Nov 22, 2017
@dgutov
Copy link
Collaborator

dgutov commented Nov 22, 2017

Yeah, ok. 😃

@dgutov dgutov closed this as completed Nov 22, 2017
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

5 participants