Hi
There is a strange compiler behavior that I don’t understand:
import kotlin.js.Date
import org.w3c.dom.Document
private external val document: Document = definedExternally
fun now(locale: String = "de-DE") =
Date().toLocaleTimeString(locale)
fun main() {
println("Hello Kotlin")
document.title = now("en-US")
fun onClick(e: dynamic) {
e.target.innerText = now()
}
val obj: dynamic = document.getElementById("_mainDIV")
obj.innerText = "Hello Kotlin"
// does complie & run
// obj.addEventListener("click", ::onClick)
// does not compile ?
obj.addEventListener("click"){ e: dynamic ->
e.target.innerText = now()
}
}
Resulting compiler error is:
Task :compileKotlin2Js FAILED
e: Y:\myWebTest\kotlin\src\main.kt: (38, 9): Expected a value of type dynamic