I want to write a scala.js wrapper around a javascript library which has an object that can be instantiated like that:
new Point({x: 10, y: 12})
Seems to be straightforward. I would like to have a coordinate case class and a wrapper around the point.
case class Coord(x: Int, y: Int)
class Point(coord: Coord) extends js.Object
That obviously doesn't work as the case class is not translated into an object literal. I could of course get rid of the Coord case class and instead pass a js.Dynamic.literal to the constructor but that is not very typesafe.
What other option do I have? Do I have to write a higher level wrapper that accepts the Coord and transforms it to an object literal before passing it to the Point object?