4 ms·
Can this call js libraries and the DOM trivially like typescript? Or does it leverage ffi?
by The_rationalist 7y ago
Can this call js libraries and the DOM trivially like typescript? Or does it leverage ffi?
- sjrd 7y agoIt'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/ https://www.scala-js.org/doc/interoperability/
- manx 7y agoMany TypeScript type definitions are also automatically converted to ScalaJS: https://github.com/oyvindberg/ScalablyTyped https://github.com/oyvindberg/ScalablyTyped
- jackcviers3 7y agoYou 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_js.html#:~:targetText=Scala.js%20lets%20you%20call,is%20of%20type%20js.Dynamic%20 http://ochrons.github.io/sjs2/doc/interoperability/calling_j....