Re:Scala.js 1.0.0-RC1
by The_rationalist on Tuesday November 26, 2019 @06:16AM
(#21637294)
Can this call js libraries and the DOM trivially like typescript? Or does it leverage ffi?
[ Parent
| on HN ]
It's exactly like TypeScript. You write type definitions or you find them online, like in TypeScript, then you can call any JavaScript API using the relevant types.
Full relevant docs at https://www.scala-js.org/doc/interoperability/
Many TypeScript type definitions are also automatically converted to ScalaJS: https://github.com/oyvindberg/ScalablyTyped
Re:Scala.js 1.0.0-RC1
by jackcviers3 on Tuesday November 26, 2019 @07:59AM
(#21637858)
You can call js directly using dynamic. From the docs[1]:
val document = js.Dynamic.global.document
val playground = document.getElementById("playground")
val newP = document.createElement("p")
newP.innerHTML = "Hello world! <i>-- DOM</i>"
playground.appendChild(newP)
1. http://ochrons.github.io/sjs2/doc/interoperability/calling_j....