scala-js/scala-js-dom

CanvasRenderingContext2D.fillStyle type is incorrect

mseddon opened this issue · 2 comments

https://github.com/scala-js/scala-js-dom/blob/master/src/main/scala/org/scalajs/dom/lib.scala#L3254

Unfortunately this means we can't actually use a gradient without resorting to silliness!

ctx.asInstanceOf[js.Dynamic].updateDynamic("fillStyle")(gradient)

The spec says:

attribute (DOMString or CanvasGradient or CanvasPattern) fillStyle; // (default black)

A possible option would obviously be to just weaken the type to js.Any, but that doesn't seem satisfactory. On the other hand, if it's all we can do, it should probably be done.

strokeStyle has the same issue.

Does anyone have any better idea how to do this?

sjrd commented

There's unfortunately nothing to do but to weaken to js.Any. Scala does not have or-types.

Hey ho. Have that then.