rainforestapp / decaf

Coffeescript to ES.next transpiler. Now maintained over at
https://github.com/juliankrispel/decaf
MIT License
106 stars 10 forks source link

Class properties are causing parse error #123

Closed carlmathisen closed 8 years ago

carlmathisen commented 8 years ago

Check it out:

class Test
  myProperty: 'value'

compiles to:

class Test {
  myProperty = "value";
}

with the error Unexpected token =

http://www.goodafternoon.co/decaf/#?evaluate=true&code=class%20Test%0A%20%20myProperty%3A%20'value' #

juliankrispel commented 8 years ago

thanks @carlmathisen that's actually an error thrown by ace editor. I'm guessing it doesn't do es7 class properties. @tsuchikazu could you maybe have a quick look?

tsuchikazu commented 8 years ago

decaf compiled correctly.

Ace editor evaluate compiled JavaScript code directly. Class Instance Fields syntax is not implemented in all browser yet. Try it page can only compile coffeescript to JavaScript code. Could you compile JavaScript code yourself by babel to evaluate?

https://babeljs.io/repl/#?evaluate=false&presets=es2015%2Cstage-1&experimental=false&loose=true&spec=true&code=class%20Test%20{%0A%20%20myProperty%20%3D%20%22value%22%3B%0A}

carlmathisen commented 8 years ago

Makes sense. Thanks!