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

convert-prototype-extensions doesn't work with spread operators #15

Open
stefanpenner opened this issue Mar 30, 2015 · 5 comments
Open
Assignees
Labels

Comments

@stefanpenner
Copy link
Collaborator

the following breaks:

foo: function() {

}.property(...FILES)

because it transpiles to:

foo: Ember.computed(...FILES, function() {

})

and because spread must be the final element in a list, or method signature, bad things happen.

@abuiles
Copy link
Owner

abuiles commented Mar 30, 2015

@kamal got some time to review?

@stefanpenner maybe can you add a failing example here https://github.com/abuiles/ember-watson/blob/master/tests/fixtures/prototype-extension-files/old.js and then we'll fix it

@stefanpenner
Copy link
Collaborator Author

actually, i think this is just a bug in recast as babel handles this fine:http://babeljs.io/repl/#?experimental=true&playground=false&evaluate=true&loose=true&spec=true&code=var%20keys%20%3D%20%5B'a'%2C%20'b'%2C%20'c'%5D%3B%0A%0Avar%20a%20%3D%20%7B%0A%20%20b%3A%20Ember.computed(...Keys%2C%20function()%20%7B%0A%20%20%20%20%0A%20%20%7D)%0A%7D

I wonder if ember-watson would be better served by using the proposed transform API that lands with babel 5x (cc @sebmck, maybe you can share resources on this)

@abuiles
Copy link
Owner

abuiles commented Mar 30, 2015

Sounds like a good excuse to use Babel's transform :P

Adolfo Builes

On Mon, Mar 30, 2015 at 12:13 PM, Stefan Penner notifications@github.com
wrote:

actually, i think this is just a bug in recast as babel handles this fine:
http://babeljs.io/repl/#?experimental=true&playground=false&evaluate=true&loose=true&spec=true&code=var%20keys%20%3D%20%5B'a'%2C%20'b'%2C%20'c'%5D%3B%0A%0Avar%20a%20%3D%20%7B%0A%20%20b%3A%20Ember.computed(...Keys%2C%20function()%20%7B%0A%20%20%20%20%0A%20%20%7D)%0A%7D


Reply to this email directly or view it on GitHub
#15 (comment).

@stefanpenner
Copy link
Collaborator Author

@sebmck has informed me, that babel isn't as good as recast when it comes to preserving input style

@stefanpenner stefanpenner changed the title prototype extension change bug: convert-prototype-extensions doesn't work with spread operators Mar 30, 2015
@kamal
Copy link
Collaborator

kamal commented Apr 1, 2015

Maybe simplest thing we can do is to detect the spread operator and call

Ember.computed.apply(Ember, KEYS.concat([function(){}])

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

3 participants