ars
ars

Reputation: 1639

Scala.js exporting abstract val/var

It seems that exporting abstract val/var with descendants like this doesn't work:

@JSExportDescendentObjects
trait T {
  @JSExport
  val i: Int
  @JSExport
  var j: Int
}

class A extends T {
  val i = 5
  var j = 10
}

I get warnings no valid targets for annotation on value i - it is discarded unused and A's i and j are not seen from Javascript. However, it is possible to export them via @JSExportAll:

@JSExportDescendentObjects
@JSExportAll
trait T {
  val i: Int
  var j: Int
}

class A extends T {
  val i = 5
  var j = 10
}

It is fine now, no warnings and i and j are visible from JS.

defs doesn't have such problem. Why is this and how can I selectively export abstract val/var?

Upvotes: 2

Views: 91

Answers (1)

sjrd
sjrd

Reputation: 22085

This was a bug in Scala.js <= 0.6.10. Upgrading to Scala.js 0.6.11 should fix your problem.

Upvotes: 4

Related Questions