Robert Jaros
08/19/2020, 12:32 PMexternal interface BtOn {
}
interface SnOn<T> : BtOn {
var self: T
}
@Suppress("UnsafeCastFromDynamic")
fun on(target: Any): SnOn<Any> {
val obj = js("{}")
obj["self"] = target
return obj
}
fun main() {
val x = on("test");
console.log(x.self);
}
It fails with x._get_self_ is not a function
. Is it a bug in the compiler backend or is my code just wrong?diesieben07
08/19/2020, 12:34 PMself
property is translated to a JS property named the same). You have to use external interface
to describe raw JS objects.andylamax
08/19/2020, 5:08 PMSnOn<T>
as an external interface
just as a workarround. This same problem is being faced by the kotlin-react
js wrapper and they gave that workarounddiesieben07
08/20/2020, 6:40 AMinterface
describes a full-blown instance of a class. Not just any random object with some properties.andylamax
08/20/2020, 11:36 AM