-
Notifications
You must be signed in to change notification settings - Fork 2k
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
ES: Allow deconstructing objects with splats #3894
Comments
Seems like #815 proposed this feature but was closed for other reasons. |
Is that really part of ES6? I've never seen it before. |
ah, you are right, it’s actually part of ES7, included in JSX. i assumed everything of JSX that isn’t /edit: babel supports it as well (demo) |
Cool! Thanks for those links! |
no problem. at closing of that other issue: luckily, that’s about something different (i.e. extending objects, not destructuring them) and @jashkenas’ argument…
…is also not valid anymore now that ECMAscript itself uses splats for objects. so this should be good to go! |
now it’s in the compat-table |
+1 for this, it would be very helpful to write React Apps in CoffeeScript with this feature. |
Hoping this is added to Coffeescript, is it going to be? |
So I'd also love to see Should these go into separate issues? |
|
Ooh, I didn't know about that, nicer syntax too! That just leaves the spread and rest operations... |
@lydell with the caveat that it doesn't work for symbols. |
Well, since @jashkenas said he considered symbols a misfeature, I guess that's fine for coffee? |
Guess so, though I don't agree we can ignore it since standard lib APIs and even syntax depend on values with symbols as keys. |
yeah, we need a way to express this ES2015 in CS: const iterable = {
*[Symbol.iterator]() {
yield 1
yield 2
}
} |
I'd just like to point out that I'm currently mostly writing JSX and that's mostly because of being able to write |
@wmertens https://github.com/jsdf/coffee-react cofee-react supports spread attributes. |
@onemanstartup yeah but I don't want to write xml. |
This is something that should probably be an issue of its own as currently the only ways to do this are: Not inheritable class SomeIterable
constructor: (...) ->
...
@[Symbol.iterator] ->
... Sort've defeats the original point of CoffeeScript classes: class SomeIterable
constructor: (...) ->
SomeIterable::[Symbol.iterator] = ->
... |
@Jamesernator This is an alternative: class SomeIterable
constructor: (...) ->
@::[Symbol.iterator] = ->
... |
Speaking of cjsx, one of the main feature of object splats (or rest parameters) in JSX is ability to do so: const {propIamGonaConsume, ...others} = props
return <SomeComponent {...others}/> As it seems to me, for now it is impossible to do in cjsx, so it would be really nice to resolve this feature request. |
Also, it's first time i found that JS can do something coffee can't |
Just use ES6 emit instead. may be coffeescript is good support to ES6 ,not ES7
|
As immutable object creation in redux etc is becoming all the rage replicating the object splat in coffeescript seems quite relevant. It would certainly be a nicer solution than using |
@jashkenas Would a PR get merged? |
It'd certainly start a discussion :-). |
+1.
nowadays this grammar is quite vital when writing react/redux and vue/vuex. hope coffee will be able to do this soon. :) |
I'd be fine with this being simply passed through so Babel can interpret it, like |
This should be supported as part of CoffeeScript 2, which will output ES2015 spread syntax. After #4311 implements the rest operator, spread in objects should probably be the next target. Help wanted. |
@GeoffreyBooth, glad to see plans on CoffeeScript 2 ~ Some es6 features do become more and more vital today: |
|
wow, didn't notice that. cool! |
Help wanted! I’ve started a destructuring branch for CoffeeScript 2 to output ES2015+ syntax for destructuring. I’m happy to invite contributors to this branch. |
Implemented via #4493. |
…for parity with ECMA7. currently we can’t do this:
The text was updated successfully, but these errors were encountered: