Skip to content

JSMacro should support union types #70

Open
@mariussoutier

Description

@mariussoutier

When using union types, one must cast to js.Any, e.g.:

case class Pie(padding: js.UndefOr[Double | Shape] = js.undefined) {
  def toJs = {
    val p = js.Dynamic.literal()
    padding.foreach(x => p.updateDynamic("padding")(x.asInstanceOf[js.Any]))
    p
  }
}

JSMacro doesn't know about this, so this compiler error comes up:

type mismatch;
 found   : scala.scalajs.js.|[Double,Shape]
 required: scala.scalajs.js.Any

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions