ghempton / ember-script

Ember-infused CoffeeScript
BSD 3-Clause "New" or "Revised" License
356 stars 27 forks source link

setTimeout / setInterval don't compile #36

Open coladarci opened 10 years ago

coladarci commented 10 years ago

This is valid coffeescript..

    setTimeout ->
      alert("OH HAI!")
    , 500

..but throws a compilation error in ember-script:

Error: Syntax error on line 140, column 4: unexpected ',' (\u002C)
137 : 
138 :     setTimeout(->
139 :       alert("OH HAI!")
140 :     , 500)

I've tried this:

    setTimeout (->
      alert("OH HAI!")
    , 500)

With the same results.

For those with the same issue, the only work around I've found is doing something like this (which does have it's own advantages):

timeoutFunction = ->
  alert("OH HAI!")
setTimeout(timeoutFunction, 500)
ghempton commented 10 years ago

EmberScript is based on coffeescript redux. Most of these issues that are related to coffeescript will hopefully eventually be fixed upstream. Here is a relevant issue: https://github.com/michaelficarra/CoffeeScriptRedux/issues/262