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

wrong conversion of IIFE syntax #190

Closed
jpillora opened this issue Mar 7, 2013 · 5 comments
Closed

wrong conversion of IIFE syntax #190

jpillora opened this issue Mar 7, 2013 · 5 comments

Comments

@jpillora
Copy link

jpillora commented Mar 7, 2013

window.foo = (function() {
    return 42;
}());

converts to:

window.foo = (->
  42
())

end braces should be: )()

@timaschew
Copy link
Member

from #150
other syntax, but also broken:

foo = function(){
  thing();
}();

gets compiled to

foo = ->
  thing()
()

when it should be

foo = (->
  thing()
)()

@timaschew
Copy link
Member

Workaround

Use this syntax and you're safe in js2coffee

// jQuery syntax: (outies)
(function (w,d) {
  // your code here
})(window, document);

@rstacruz
Copy link
Member

rstacruz commented Feb 1, 2015

now gets converted to:

window.foo = do ->
  42

demo

@jpillora
Copy link
Author

jpillora commented Feb 1, 2015

nice work with the new version, what's the purpose of the "preview" window? did people not like the two-way conversion?

@rstacruz
Copy link
Member

rstacruz commented Feb 1, 2015

mostly i felt it was ambiguous—you weren't sure if you were in js->coffee mode or coffee->js mode. moreso, i dont want to encourage the behavior of getting CoffeeScript output and passing it back to js2coffee :)

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

No branches or pull requests

3 participants