riot/compiler

Compile object functions issue

Closed this issue · 3 comments

Example:

<riot-tag>
  let foo = {
    bar() {  }
  }
  buzz() { }
</riot-tag>

compiles to

let foo = {
  this.bar = function() {}
}
this.buzz = function() {}

@SPAHI4 , native riot parser is for es5 only, you need use <script type="babel"> or compile with the CLI --type=babel option.

Anyway, what is the output you expect?

@aMarCruz I'm expecting

let foo = {
  bar() {}
}
this.buzz = function() {}

@SPAHI4 , sorry by the delay.
Well, the default parser (riotjs) is for ES5 and can't handle this constructions.
You can use babel with ES2015 or riotjs with ES5, but not both.

I don't know Babel, but I think that the output should be something as

var foo = {
  bar: function() {}
}
this.buzz = function() {}

There's no problems with the riot parser here, so I'm closing this issue.