问题
Despite it compiles and runs in sbt console. Intellij complains that I should have Binding[Node] instead of Elem in editor.
@dom def renderDiv: Binding[Div] = <div>...</div>
From intellij IDEA's perspective, this method returns a Elem
which is a subtype of scala.xml.Node
,
but when rendering:
dom.render(document.getElementById("root"),renderDiv)
it requires a org.scalajs.dom.raw.Node
.
Is there any workaround to this?
回答1:
Could put an implicit conversion def in scope:
package object xxx {
implicit def makeIntellijHappy[T<:org.scalajs.dom.raw.Node](x: scala.xml.Node): Binding[T] =
throw new AssertionError("This should never execute.")
}
define method above in the package object, thus it covers the whole package. This method will never be executed, actually.
来源:https://stackoverflow.com/questions/42617401/how-to-suppress-intellij-idea-error-in-editor-when-using-binding-scala-macro-ann